fail_definition_imported.carbon 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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+7]]:1: error: duplicate name being declared in the same scope
  17. // CHECK:STDERR: interface I {}
  18. // CHECK:STDERR: ^~~~~~~~~~~~~
  19. // CHECK:STDERR: fail_b.carbon:[[@LINE-5]]:1: in import
  20. // CHECK:STDERR: a.carbon:4:1: note: name is previously declared here
  21. // CHECK:STDERR: interface I;
  22. // CHECK:STDERR: ^~~~~~~~~~~~
  23. interface I {}
  24. // CHECK:STDOUT: --- a.carbon
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: constants {
  27. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: file {
  31. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  32. // CHECK:STDOUT: .I = %I.decl
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} {}
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: interface @I;
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: --- fail_b.carbon
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: constants {
  42. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  43. // CHECK:STDOUT: %.2: type = interface_type @.1 [template]
  44. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: imports {
  48. // CHECK:STDOUT: %import_ref: type = import_ref Main//a, inst+1, loaded [template = constants.%.1]
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: file {
  52. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  53. // CHECK:STDOUT: .I = imports.%import_ref
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %default.import = import <invalid>
  56. // CHECK:STDOUT: %.decl: type = interface_decl @.1 [template = constants.%.2] {} {}
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: interface @I;
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: interface @.1 {
  62. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: !members:
  65. // CHECK:STDOUT: .Self = %Self
  66. // CHECK:STDOUT: witness = ()
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: