fail_redefinition.carbon 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/fail_redefinition.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_redefinition.carbon
  14. interface I {}
  15. impl i32 as I {}
  16. // CHECK:STDERR: fail_redefinition.carbon:[[@LINE+7]]:1: error: redefinition of `impl i32 as I` [ImplRedefinition]
  17. // CHECK:STDERR: impl i32 as I {}
  18. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  19. // CHECK:STDERR: fail_redefinition.carbon:[[@LINE-5]]:1: note: previous definition was here [ImplPreviousDefinition]
  20. // CHECK:STDERR: impl i32 as I {}
  21. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  22. // CHECK:STDERR:
  23. impl i32 as I {}
  24. // CHECK:STDOUT: --- fail_redefinition.carbon
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: constants {
  27. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  28. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic]
  29. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  30. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  31. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  32. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  33. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness @i32.as.I.impl.a9e516.1.%I.impl_witness_table [concrete]
  34. // CHECK:STDOUT: %I.facet: %I.type = facet_value %i32, (%I.impl_witness) [concrete]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: imports {
  38. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  39. // CHECK:STDOUT: .Int = %Core.Int
  40. // CHECK:STDOUT: import Core//prelude
  41. // CHECK:STDOUT: import Core//prelude/...
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: file {
  47. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  48. // CHECK:STDOUT: .Core = imports.%Core
  49. // CHECK:STDOUT: .I = %I.decl
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %Core.import = import Core
  52. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  53. // CHECK:STDOUT: impl_decl @i32.as.I.impl.a9e516.1 [concrete] {} {
  54. // CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
  55. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: impl_decl @i32.as.I.impl.a9e516.2 [concrete] {} {
  58. // CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
  59. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: interface @I {
  64. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = constants.%Self]
  65. // CHECK:STDOUT: %I.WithSelf.decl = interface_with_self_decl @I [concrete]
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: !members:
  68. // CHECK:STDOUT: .Self = %Self
  69. // CHECK:STDOUT: witness = ()
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: !requires:
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: impl @i32.as.I.impl.a9e516.1: %i32 as %I.ref {
  75. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (), @i32.as.I.impl.a9e516.1 [concrete]
  76. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness %I.impl_witness_table [concrete = constants.%I.impl_witness]
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: !members:
  79. // CHECK:STDOUT: witness = %I.impl_witness
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: impl @i32.as.I.impl.a9e516.2: %i32 as %I.ref {
  83. // CHECK:STDOUT: !members:
  84. // CHECK:STDOUT: witness = <error>
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: specific @I.WithSelf(constants.%Self) {
  88. // CHECK:STDOUT: !definition:
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: specific @I.WithSelf(constants.%I.facet) {
  92. // CHECK:STDOUT: !definition:
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: