fail_conflict_imported_namespace_first.carbon 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon
  10. // --- namespace.carbon
  11. package Example library "namespace";
  12. namespace NS;
  13. // --- fail_conflict.carbon
  14. package Example;
  15. import library "namespace";
  16. // CHECK:STDERR: fail_conflict.carbon:[[@LINE+9]]:1: ERROR: Duplicate name being declared in the same scope.
  17. // CHECK:STDERR: fn NS();
  18. // CHECK:STDERR: ^~~~~~~~
  19. // CHECK:STDERR: fail_conflict.carbon:[[@LINE-5]]:1: In import.
  20. // CHECK:STDERR: import library "namespace";
  21. // CHECK:STDERR: ^~~~~~
  22. // CHECK:STDERR: namespace.carbon:4:1: Name is previously declared here.
  23. // CHECK:STDERR: namespace NS;
  24. // CHECK:STDERR: ^~~~~~~~~~~~~
  25. fn NS();
  26. fn NS.Foo();
  27. // CHECK:STDOUT: --- namespace.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  31. // CHECK:STDOUT: .Core = %Core
  32. // CHECK:STDOUT: .NS = %NS
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  35. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {}
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: --- fail_conflict.carbon
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: constants {
  41. // CHECK:STDOUT: %.type: type = fn_type @.1 [template]
  42. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  43. // CHECK:STDOUT: %.2: %.type = struct_value () [template]
  44. // CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
  45. // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: file {
  49. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  50. // CHECK:STDOUT: .NS = %NS
  51. // CHECK:STDOUT: .Core = %Core
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %import_ref: <namespace> = import_ref ir1, inst+2, loaded
  54. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref, [template] {
  55. // CHECK:STDOUT: .Foo = %Foo.decl
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  58. // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.2] {}
  59. // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {}
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: fn @.1();
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @Foo();
  65. // CHECK:STDOUT: