core_name_poisoning.carbon 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/packages/core_name_poisoning.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/packages/core_name_poisoning.carbon
  12. // --- fail_implicitly_poison_core.carbon
  13. library "[[@TEST_NAME]]";
  14. // CHECK:STDERR: fail_implicitly_poison_core.carbon:[[@LINE+4]]:9: error: `Core.Bool` implicitly referenced here, but package `Core` not found [CoreNotFound]
  15. // CHECK:STDERR: fn F(x: bool);
  16. // CHECK:STDERR: ^~~~
  17. // CHECK:STDERR:
  18. fn F(x: bool);
  19. class r#Core {}
  20. // --- fail_poisoned_core.carbon
  21. package Core library "[[@TEST_NAME]]";
  22. // This introduces a poisoned name in `Core`.
  23. // CHECK:STDERR: fail_poisoned_core.carbon:[[@LINE+4]]:8: error: name `Core.Int` implicitly referenced here, but not found [CoreNameNotFound]
  24. // CHECK:STDERR: var x: i32;
  25. // CHECK:STDERR: ^~~
  26. // CHECK:STDERR:
  27. var x: i32;
  28. // --- fail_use_poisoned_core.carbon
  29. library "[[@TEST_NAME]]";
  30. import Core library "poisoned_core";
  31. // This accesses the poisoned name in `Core`.
  32. // CHECK:STDERR: fail_use_poisoned_core.carbon:[[@LINE+4]]:9: error: name `Core.Int` implicitly referenced here, but not found [CoreNameNotFound]
  33. // CHECK:STDERR: fn F(b: i32);
  34. // CHECK:STDERR: ^~~
  35. // CHECK:STDERR:
  36. fn F(b: i32);