fail_redeclare_member.carbon 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --no-prelude-import --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/fail_redeclare_member.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/fail_redeclare_member.carbon
  13. interface Interface {
  14. fn F();
  15. // CHECK:STDERR: fail_redeclare_member.carbon:[[@LINE+7]]:6: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate]
  16. // CHECK:STDERR: fn F();
  17. // CHECK:STDERR: ^
  18. // CHECK:STDERR: fail_redeclare_member.carbon:[[@LINE-4]]:3: note: name is previously declared here [NameDeclPrevious]
  19. // CHECK:STDERR: fn F();
  20. // CHECK:STDERR: ^~~~~~~
  21. // CHECK:STDERR:
  22. fn F();
  23. }
  24. // CHECK:STDOUT: --- fail_redeclare_member.carbon
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: constants {
  27. // CHECK:STDOUT: %Interface.type: type = facet_type <@Interface> [concrete]
  28. // CHECK:STDOUT: %Self: %Interface.type = bind_symbolic_name Self, 0 [symbolic]
  29. // CHECK:STDOUT: %F.type.1ad64d.1: type = fn_type @F.1 [concrete]
  30. // CHECK:STDOUT: %F.5d382e.1: %F.type.1ad64d.1 = struct_value () [concrete]
  31. // CHECK:STDOUT: %Interface.assoc_type: type = assoc_entity_type @Interface [concrete]
  32. // CHECK:STDOUT: %assoc0: %Interface.assoc_type = assoc_entity element0, @Interface.%F.decl.loc15 [concrete]
  33. // CHECK:STDOUT: %F.type.1ad64d.2: type = fn_type @F.2 [concrete]
  34. // CHECK:STDOUT: %F.5d382e.2: %F.type.1ad64d.2 = struct_value () [concrete]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file {
  38. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  39. // CHECK:STDOUT: .Interface = %Interface.decl
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [concrete = constants.%Interface.type] {} {}
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: interface @Interface {
  45. // CHECK:STDOUT: %Self: %Interface.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  46. // CHECK:STDOUT: %F.decl.loc15: %F.type.1ad64d.1 = fn_decl @F.1 [concrete = constants.%F.5d382e.1] {} {}
  47. // CHECK:STDOUT: %assoc0: %Interface.assoc_type = assoc_entity element0, %F.decl.loc15 [concrete = constants.%assoc0]
  48. // CHECK:STDOUT: %F.decl.loc23: %F.type.1ad64d.2 = fn_decl @F.2 [concrete = constants.%F.5d382e.2] {} {}
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: !members:
  51. // CHECK:STDOUT: .Self = %Self
  52. // CHECK:STDOUT: .F = %assoc0
  53. // CHECK:STDOUT: witness = (%F.decl.loc15)
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: generic fn @F.1(@Interface.%Self: %Interface.type) {
  57. // CHECK:STDOUT: fn();
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: generic fn @F.2(@Interface.%Self: %Interface.type) {
  61. // CHECK:STDOUT: fn();
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: specific @F.1(constants.%Self) {}
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: specific @F.2(constants.%Self) {}
  67. // CHECK:STDOUT: