fail_redeclare_member.carbon 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_redeclare_member.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_redeclare_member.carbon
  10. interface Interface {
  11. fn F();
  12. // CHECK:STDERR: fail_redeclare_member.carbon:[[@LINE+7]]:6: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate]
  13. // CHECK:STDERR: fn F();
  14. // CHECK:STDERR: ^
  15. // CHECK:STDERR: fail_redeclare_member.carbon:[[@LINE-4]]:3: note: name is previously declared here [NameDeclPrevious]
  16. // CHECK:STDERR: fn F();
  17. // CHECK:STDERR: ^~~~~~~
  18. // CHECK:STDERR:
  19. fn F();
  20. }
  21. // CHECK:STDOUT: --- fail_redeclare_member.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Interface.type: type = facet_type <@Interface> [concrete]
  25. // CHECK:STDOUT: %Self: %Interface.type = bind_symbolic_name Self, 0 [symbolic]
  26. // CHECK:STDOUT: %F.type.1ad64d.1: type = fn_type @F.1 [concrete]
  27. // CHECK:STDOUT: %F.5d382e.1: %F.type.1ad64d.1 = struct_value () [concrete]
  28. // CHECK:STDOUT: %Interface.assoc_type: type = assoc_entity_type @Interface [concrete]
  29. // CHECK:STDOUT: %assoc0: %Interface.assoc_type = assoc_entity element0, @Interface.%F.decl.loc12 [concrete]
  30. // CHECK:STDOUT: %F.type.1ad64d.2: type = fn_type @F.2 [concrete]
  31. // CHECK:STDOUT: %F.5d382e.2: %F.type.1ad64d.2 = struct_value () [concrete]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  36. // CHECK:STDOUT: .Interface = %Interface.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [concrete = constants.%Interface.type] {} {}
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: interface @Interface {
  42. // CHECK:STDOUT: %Self: %Interface.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  43. // CHECK:STDOUT: %F.decl.loc12: %F.type.1ad64d.1 = fn_decl @F.1 [concrete = constants.%F.5d382e.1] {} {}
  44. // CHECK:STDOUT: %assoc0: %Interface.assoc_type = assoc_entity element0, %F.decl.loc12 [concrete = constants.%assoc0]
  45. // CHECK:STDOUT: %F.decl.loc20: %F.type.1ad64d.2 = fn_decl @F.2 [concrete = constants.%F.5d382e.2] {} {}
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: !members:
  48. // CHECK:STDOUT: .Self = %Self
  49. // CHECK:STDOUT: .F = %assoc0
  50. // CHECK:STDOUT: witness = (%F.decl.loc12)
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: generic fn @F.1(@Interface.%Self: %Interface.type) {
  54. // CHECK:STDOUT: fn();
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: generic fn @F.2(@Interface.%Self: %Interface.type) {
  58. // CHECK:STDOUT: fn();
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: specific @F.1(constants.%Self) {}
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: specific @F.2(constants.%Self) {}
  64. // CHECK:STDOUT: