fail_call_invalid.carbon 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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_call_invalid.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_call_invalid.carbon
  10. interface Simple {
  11. fn G[self: Self]();
  12. }
  13. impl i32 as Simple {
  14. // CHECK:STDERR: fail_call_invalid.carbon:[[@LINE+4]]:14: error: name `Undeclared` not found [NameNotFound]
  15. // CHECK:STDERR: fn G[self: Undeclared]();
  16. // CHECK:STDERR: ^~~~~~~~~~
  17. // CHECK:STDERR:
  18. fn G[self: Undeclared]();
  19. }
  20. fn InstanceCall(n: i32) {
  21. n.(Simple.G)();
  22. }
  23. // CHECK:STDOUT: --- fail_call_invalid.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %Simple.type: type = facet_type <@Simple> [concrete]
  27. // CHECK:STDOUT: %Self.3c9: %Simple.type = bind_symbolic_name Self, 0 [symbolic]
  28. // CHECK:STDOUT: %Self.as_type.716: type = facet_access_type %Self.3c9 [symbolic]
  29. // CHECK:STDOUT: %G.type.b60: type = fn_type @G.1 [concrete]
  30. // CHECK:STDOUT: %G.cb0: %G.type.b60 = struct_value () [concrete]
  31. // CHECK:STDOUT: %Simple.assoc_type: type = assoc_entity_type %Simple.type [concrete]
  32. // CHECK:STDOUT: %assoc0.45f: %Simple.assoc_type = assoc_entity element0, @Simple.%G.decl [concrete]
  33. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  34. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  35. // CHECK:STDOUT: %impl_witness.85b: <witness> = impl_witness (<error>) [concrete]
  36. // CHECK:STDOUT: %G.type.c98: type = fn_type @G.2 [concrete]
  37. // CHECK:STDOUT: %G.e73: %G.type.c98 = struct_value () [concrete]
  38. // CHECK:STDOUT: %Simple.facet: %Simple.type = facet_value %i32, (%impl_witness.85b) [concrete]
  39. // CHECK:STDOUT: %InstanceCall.type: type = fn_type @InstanceCall [concrete]
  40. // CHECK:STDOUT: %InstanceCall: %InstanceCall.type = struct_value () [concrete]
  41. // CHECK:STDOUT: %.e92: type = fn_type_with_self_type %G.type.b60, %Simple.facet [concrete]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: imports {
  45. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  46. // CHECK:STDOUT: .Int = %Core.Int
  47. // CHECK:STDOUT: import Core//prelude
  48. // CHECK:STDOUT: import Core//prelude/...
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: file {
  53. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  54. // CHECK:STDOUT: .Core = imports.%Core
  55. // CHECK:STDOUT: .Simple = %Simple.decl
  56. // CHECK:STDOUT: .Undeclared = <poisoned>
  57. // CHECK:STDOUT: .InstanceCall = %InstanceCall.decl
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT: %Core.import = import Core
  60. // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [concrete = constants.%Simple.type] {} {}
  61. // CHECK:STDOUT: impl_decl @impl.006 [concrete] {} {
  62. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  63. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  64. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple.type]
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (<error>) [concrete = constants.%impl_witness.85b]
  67. // CHECK:STDOUT: %InstanceCall.decl: %InstanceCall.type = fn_decl @InstanceCall [concrete = constants.%InstanceCall] {
  68. // CHECK:STDOUT: %n.patt: %i32 = binding_pattern n
  69. // CHECK:STDOUT: %n.param_patt: %i32 = value_param_pattern %n.patt, call_param0
  70. // CHECK:STDOUT: } {
  71. // CHECK:STDOUT: %n.param: %i32 = value_param call_param0
  72. // CHECK:STDOUT: %.loc23: type = splice_block %i32 [concrete = constants.%i32] {
  73. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  74. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: %n: %i32 = bind_name n, %n.param
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: interface @Simple {
  81. // CHECK:STDOUT: %Self: %Simple.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.3c9]
  82. // CHECK:STDOUT: %G.decl: %G.type.b60 = fn_decl @G.1 [concrete = constants.%G.cb0] {
  83. // CHECK:STDOUT: %self.patt: @G.1.%Self.as_type.loc12_14.1 (%Self.as_type.716) = binding_pattern self
  84. // CHECK:STDOUT: %self.param_patt: @G.1.%Self.as_type.loc12_14.1 (%Self.as_type.716) = value_param_pattern %self.patt, call_param0
  85. // CHECK:STDOUT: } {
  86. // CHECK:STDOUT: %self.param: @G.1.%Self.as_type.loc12_14.1 (%Self.as_type.716) = value_param call_param0
  87. // CHECK:STDOUT: %.loc12_14.1: type = splice_block %.loc12_14.2 [symbolic = %Self.as_type.loc12_14.1 (constants.%Self.as_type.716)] {
  88. // CHECK:STDOUT: %Self.ref: %Simple.type = name_ref Self, @Simple.%Self [symbolic = %Self (constants.%Self.3c9)]
  89. // CHECK:STDOUT: %Self.as_type.loc12_14.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc12_14.1 (constants.%Self.as_type.716)]
  90. // CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref, %Self.as_type.loc12_14.2 [symbolic = %Self.as_type.loc12_14.1 (constants.%Self.as_type.716)]
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: %self: @G.1.%Self.as_type.loc12_14.1 (%Self.as_type.716) = bind_name self, %self.param
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: %assoc0: %Simple.assoc_type = assoc_entity element0, %G.decl [concrete = constants.%assoc0.45f]
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: !members:
  97. // CHECK:STDOUT: .Self = %Self
  98. // CHECK:STDOUT: .G = %assoc0
  99. // CHECK:STDOUT: witness = (%G.decl)
  100. // CHECK:STDOUT: }
  101. // CHECK:STDOUT:
  102. // CHECK:STDOUT: impl @impl.006: %i32 as %Simple.ref {
  103. // CHECK:STDOUT: %G.decl: %G.type.c98 = fn_decl @G.2 [concrete = constants.%G.e73] {
  104. // CHECK:STDOUT: %self.patt: <error> = binding_pattern self
  105. // CHECK:STDOUT: %self.param_patt: <error> = value_param_pattern %self.patt, call_param0 [concrete = <error>]
  106. // CHECK:STDOUT: } {
  107. // CHECK:STDOUT: %self.param: <error> = value_param call_param0
  108. // CHECK:STDOUT: %Undeclared.ref: <error> = name_ref Undeclared, <error> [concrete = <error>]
  109. // CHECK:STDOUT: %self: <error> = bind_name self, %self.param
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: !members:
  113. // CHECK:STDOUT: .Undeclared = <poisoned>
  114. // CHECK:STDOUT: .G = %G.decl
  115. // CHECK:STDOUT: witness = file.%impl_witness
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: generic fn @G.1(@Simple.%Self: %Simple.type) {
  119. // CHECK:STDOUT: %Self: %Simple.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.3c9)]
  120. // CHECK:STDOUT: %Self.as_type.loc12_14.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc12_14.1 (constants.%Self.as_type.716)]
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: fn[%self.param_patt: @G.1.%Self.as_type.loc12_14.1 (%Self.as_type.716)]();
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT:
  125. // CHECK:STDOUT: fn @G.2[%self.param_patt: <error>]();
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: fn @InstanceCall(%n.param_patt: %i32) {
  128. // CHECK:STDOUT: !entry:
  129. // CHECK:STDOUT: %n.ref: %i32 = name_ref n, %n
  130. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple.type]
  131. // CHECK:STDOUT: %G.ref: %Simple.assoc_type = name_ref G, @Simple.%assoc0 [concrete = constants.%assoc0.45f]
  132. // CHECK:STDOUT: %impl.elem0: %.e92 = impl_witness_access constants.%impl_witness.85b, element0 [concrete = <error>]
  133. // CHECK:STDOUT: return
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: specific @G.1(constants.%Self.3c9) {
  137. // CHECK:STDOUT: %Self => constants.%Self.3c9
  138. // CHECK:STDOUT: %Self.as_type.loc12_14.1 => constants.%Self.as_type.716
  139. // CHECK:STDOUT: }
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: specific @G.1(constants.%Simple.facet) {
  142. // CHECK:STDOUT: %Self => constants.%Simple.facet
  143. // CHECK:STDOUT: %Self.as_type.loc12_14.1 => constants.%i32
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT: