fail_method_redefinition.carbon 2.9 KB

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