fail_call_invalid.carbon 7.9 KB

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