fail_definition_imported.carbon 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/fail_definition_imported.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/fail_definition_imported.carbon
  14. // --- a.carbon
  15. library "[[@TEST_NAME]]";
  16. interface I;
  17. // --- fail_b.carbon
  18. library "[[@TEST_NAME]]";
  19. import library "a";
  20. // CHECK:STDERR: fail_b.carbon:[[@LINE+8]]:11: error: duplicate name `I` being declared in the same scope [NameDeclDuplicate]
  21. // CHECK:STDERR: interface I {}
  22. // CHECK:STDERR: ^
  23. // CHECK:STDERR: fail_b.carbon:[[@LINE-5]]:1: in import [InImport]
  24. // CHECK:STDERR: a.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
  25. // CHECK:STDERR: interface I;
  26. // CHECK:STDERR: ^~~~~~~~~~~~
  27. // CHECK:STDERR:
  28. interface I {}
  29. // CHECK:STDOUT: --- a.carbon
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: constants {
  32. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  37. // CHECK:STDOUT: .I = %I.decl
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: interface @I;
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: --- fail_b.carbon
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: constants {
  47. // CHECK:STDOUT: %I.type.11614e.1: type = facet_type <@I.1> [concrete]
  48. // CHECK:STDOUT: %I.type.11614e.2: type = facet_type <@I.loc13> [concrete]
  49. // CHECK:STDOUT: %Self: %I.type.11614e.2 = symbolic_binding Self, 0 [symbolic]
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: imports {
  53. // CHECK:STDOUT: %Main.I: type = import_ref Main//a, I, loaded [concrete = constants.%I.type.11614e.1]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: file {
  57. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  58. // CHECK:STDOUT: .I = imports.%Main.I
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %default.import = import <none>
  61. // CHECK:STDOUT: %I.decl: type = interface_decl @I.loc13 [concrete = constants.%I.type.11614e.2] {} {}
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: interface @I.1 [from "a.carbon"];
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: interface @I.loc13 {
  67. // CHECK:STDOUT: %Self: %I.type.11614e.2 = symbolic_binding Self, 0 [symbolic = constants.%Self]
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: !members:
  70. // CHECK:STDOUT: .Self = %Self
  71. // CHECK:STDOUT: witness = ()
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: !requires:
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: