fail_definition_imported.carbon 2.8 KB

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