fail_method_redefinition.carbon 3.2 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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --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/class/fail_method_redefinition.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_method_redefinition.carbon
  13. class Class {
  14. fn F() {}
  15. // CHECK:STDERR: fail_method_redefinition.carbon:[[@LINE+7]]:3: error: redefinition of `fn F` [RedeclRedef]
  16. // CHECK:STDERR: fn F() {}
  17. // CHECK:STDERR: ^~~~~~~~
  18. // CHECK:STDERR: fail_method_redefinition.carbon:[[@LINE-4]]:3: note: previously defined here [RedeclPrevDef]
  19. // CHECK:STDERR: fn F() {}
  20. // CHECK:STDERR: ^~~~~~~~
  21. // CHECK:STDERR:
  22. fn F() {}
  23. }
  24. // CHECK:STDOUT: --- fail_method_redefinition.carbon
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: constants {
  27. // CHECK:STDOUT: %Class: type = class_type @Class [concrete]
  28. // CHECK:STDOUT: %F.type.f1baa3.1: type = fn_type @F.1 [concrete]
  29. // CHECK:STDOUT: %F.1f2582.1: %F.type.f1baa3.1 = struct_value () [concrete]
  30. // CHECK:STDOUT: %F.type.f1baa3.2: type = fn_type @F.2 [concrete]
  31. // CHECK:STDOUT: %F.1f2582.2: %F.type.f1baa3.2 = struct_value () [concrete]
  32. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  33. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: imports {
  37. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  38. // CHECK:STDOUT: import Core//prelude
  39. // CHECK:STDOUT: import Core//prelude/...
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: file {
  44. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  45. // CHECK:STDOUT: .Core = imports.%Core
  46. // CHECK:STDOUT: .Class = %Class.decl
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: %Core.import = import Core
  49. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [concrete = constants.%Class] {} {}
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: class @Class {
  53. // CHECK:STDOUT: %F.decl.loc15: %F.type.f1baa3.1 = fn_decl @F.1 [concrete = constants.%F.1f2582.1] {} {}
  54. // CHECK:STDOUT: %F.decl.loc23: %F.type.f1baa3.2 = fn_decl @F.2 [concrete = constants.%F.1f2582.2] {} {}
  55. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  56. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  57. // CHECK:STDOUT: complete_type_witness = %complete_type
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: !members:
  60. // CHECK:STDOUT: .Self = constants.%Class
  61. // CHECK:STDOUT: .F = %F.decl.loc15
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @F.1() {
  65. // CHECK:STDOUT: !entry:
  66. // CHECK:STDOUT: return
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: fn @F.2() {
  70. // CHECK:STDOUT: !entry:
  71. // CHECK:STDOUT: return
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: