fail_redefinition.carbon 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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/impl/fail_redefinition.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_redefinition.carbon
  10. interface I {}
  11. impl i32 as I {}
  12. // CHECK:STDERR: fail_redefinition.carbon:[[@LINE+6]]:1: ERROR: Redefinition of `impl i32 as I`.
  13. // CHECK:STDERR: impl i32 as I {}
  14. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  15. // CHECK:STDERR: fail_redefinition.carbon:[[@LINE-5]]:1: Previous definition was here.
  16. // CHECK:STDERR: impl i32 as I {}
  17. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  18. impl i32 as I {}
  19. // CHECK:STDOUT: --- fail_redefinition.carbon
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: constants {
  22. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  23. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  24. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  25. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  26. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  27. // CHECK:STDOUT: %.3: <witness> = interface_witness () [template]
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: imports {
  31. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  32. // CHECK:STDOUT: .Int32 = %import_ref
  33. // CHECK:STDOUT: import Core//prelude
  34. // CHECK:STDOUT: import Core//prelude/operators
  35. // CHECK:STDOUT: import Core//prelude/types
  36. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  37. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  38. // CHECK:STDOUT: import Core//prelude/operators/comparison
  39. // CHECK:STDOUT: import Core//prelude/types/bool
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: file {
  45. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  46. // CHECK:STDOUT: .Core = imports.%Core
  47. // CHECK:STDOUT: .I = %I.decl
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core.import = import Core
  50. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {}
  51. // CHECK:STDOUT: impl_decl @impl {
  52. // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32]
  53. // CHECK:STDOUT: %.loc13_6.1: type = value_of_initializer %int.make_type_32.loc13 [template = i32]
  54. // CHECK:STDOUT: %.loc13_6.2: type = converted %int.make_type_32.loc13, %.loc13_6.1 [template = i32]
  55. // CHECK:STDOUT: %I.ref.loc13: type = name_ref I, %I.decl [template = constants.%.1]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: impl_decl @impl {
  58. // CHECK:STDOUT: %int.make_type_32.loc21: init type = call constants.%Int32() [template = i32]
  59. // CHECK:STDOUT: %.loc21_6.1: type = value_of_initializer %int.make_type_32.loc21 [template = i32]
  60. // CHECK:STDOUT: %.loc21_6.2: type = converted %int.make_type_32.loc21, %.loc21_6.1 [template = i32]
  61. // CHECK:STDOUT: %I.ref.loc21: type = name_ref I, %I.decl [template = constants.%.1]
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: interface @I {
  66. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: !members:
  69. // CHECK:STDOUT: .Self = %Self
  70. // CHECK:STDOUT: witness = ()
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: impl @impl: i32 as %.1 {
  74. // CHECK:STDOUT: !members:
  75. // CHECK:STDOUT: witness = <unexpected>.inst+18
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  79. // CHECK:STDOUT: