fail_redeclare_member.carbon 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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: 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 @Interface, %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: fn @F()
  54. // CHECK:STDOUT: generic [@Interface.%Self: %.1];
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: fn @.1()
  57. // CHECK:STDOUT: generic [@Interface.%Self: %.1];
  58. // CHECK:STDOUT: