fail_conflict_imported_namespace_second.carbon 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_second.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_second.carbon
  10. // --- fn.carbon
  11. package Example library "fn";
  12. fn NS();
  13. // --- fail_conflict.carbon
  14. package Example;
  15. import library "fn";
  16. // CHECK:STDERR: fail_conflict.carbon:[[@LINE+10]]:1: ERROR: Duplicate name being declared in the same scope.
  17. // CHECK:STDERR: namespace NS;
  18. // CHECK:STDERR: ^~~~~~~~~~~~~
  19. // CHECK:STDERR: fail_conflict.carbon:[[@LINE-5]]:1: In import.
  20. // CHECK:STDERR: import library "fn";
  21. // CHECK:STDERR: ^~~~~~
  22. // CHECK:STDERR: fn.carbon:4:1: Name is previously declared here.
  23. // CHECK:STDERR: fn NS();
  24. // CHECK:STDERR: ^~~~~~~~
  25. // CHECK:STDERR:
  26. namespace NS;
  27. // CHECK:STDERR: fail_conflict.carbon:[[@LINE+9]]:4: ERROR: Name qualifiers are only allowed for entities that provide a scope.
  28. // CHECK:STDERR: fn NS.Foo();
  29. // CHECK:STDERR: ^~
  30. // CHECK:STDERR: fail_conflict.carbon:[[@LINE-17]]:1: In import.
  31. // CHECK:STDERR: import library "fn";
  32. // CHECK:STDERR: ^~~~~~
  33. // CHECK:STDERR: fn.carbon:4:1: Referenced non-scope entity declared here.
  34. // CHECK:STDERR: fn NS();
  35. // CHECK:STDERR: ^~~~~~~~
  36. fn NS.Foo();
  37. // CHECK:STDOUT: --- fn.carbon
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: constants {
  40. // CHECK:STDOUT: %NS.type: type = fn_type @NS [template]
  41. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  42. // CHECK:STDOUT: %NS: %NS.type = struct_value () [template]
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: file {
  46. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  47. // CHECK:STDOUT: .Core = %Core
  48. // CHECK:STDOUT: .NS = %NS.decl
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  51. // CHECK:STDOUT: %NS.decl: %NS.type = fn_decl @NS [template = constants.%NS] {}
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: fn @NS();
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: --- fail_conflict.carbon
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: constants {
  59. // CHECK:STDOUT: %NS.type: type = fn_type @NS [template]
  60. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  61. // CHECK:STDOUT: %NS: %NS.type = struct_value () [template]
  62. // CHECK:STDOUT: %.type: type = fn_type @.1 [template]
  63. // CHECK:STDOUT: %.2: %.type = struct_value () [template]
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: file {
  67. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  68. // CHECK:STDOUT: .NS = %import_ref
  69. // CHECK:STDOUT: .Core = %Core
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: %import_ref: %NS.type = import_ref ir1, inst+2, loaded [template = constants.%NS]
  72. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  73. // CHECK:STDOUT: %.loc16: <namespace> = namespace [template] {}
  74. // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.2] {}
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: fn @NS();
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: fn @.1();
  80. // CHECK:STDOUT: