fail_redeclare_member.carbon 2.9 KB

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