undefined.carbon 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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/function/generic/undefined.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/undefined.carbon
  10. // --- call_defined.carbon
  11. library "[[@TEST_NAME]]";
  12. fn Defined[T:! type](x: T) -> T {
  13. return x;
  14. }
  15. fn CallDefined() -> i32 {
  16. return Defined(0 as i32);
  17. }
  18. // --- call_defined_late.carbon
  19. library "[[@TEST_NAME]]";
  20. fn Defined[T:! type](x: T) -> T;
  21. fn CallDefined() -> i32 {
  22. return Defined(0 as i32);
  23. }
  24. fn Defined[T:! type](x: T) -> T {
  25. return x;
  26. }
  27. // --- fail_call_undefined.carbon
  28. library "[[@TEST_NAME]]";
  29. fn Undefined[T:! type](x: T) -> T;
  30. fn CallUndefined() -> i32 {
  31. // CHECK:STDERR: fail_call_undefined.carbon:[[@LINE+6]]:10: error: use of undefined generic function [MissingGenericFunctionDefinition]
  32. // CHECK:STDERR: return Undefined(0 as i32);
  33. // CHECK:STDERR: ^~~~~~~~~
  34. // CHECK:STDERR: fail_call_undefined.carbon:[[@LINE-6]]:1: note: generic function declared here [MissingGenericFunctionDefinitionHere]
  35. // CHECK:STDERR: fn Undefined[T:! type](x: T) -> T;
  36. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37. return Undefined(0 as i32);
  38. }
  39. // CHECK:STDOUT: --- call_defined.carbon
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: constants {
  42. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  43. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  44. // CHECK:STDOUT: %Defined.type: type = fn_type @Defined [template]
  45. // CHECK:STDOUT: %Defined: %Defined.type = struct_value () [template]
  46. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  47. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  48. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  49. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  50. // CHECK:STDOUT: %CallDefined.type: type = fn_type @CallDefined [template]
  51. // CHECK:STDOUT: %CallDefined: %CallDefined.type = struct_value () [template]
  52. // CHECK:STDOUT: %int_0.1: Core.IntLiteral = int_value 0 [template]
  53. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @As(%i32) [template]
  54. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.7, @impl.5(%int_32) [template]
  55. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  56. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.14) [template]
  57. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0.1, %Convert.14 [template]
  58. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.7(%int_32) [template]
  59. // CHECK:STDOUT: %int_0.2: %i32 = int_value 0 [template]
  60. // CHECK:STDOUT: %Defined.specific_fn: <specific function> = specific_function %Defined, @Defined(%i32) [template]
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: imports {
  64. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  65. // CHECK:STDOUT: .Int = %import_ref.1
  66. // CHECK:STDOUT: .As = %import_ref.2
  67. // CHECK:STDOUT: import Core//prelude
  68. // CHECK:STDOUT: import Core//prelude/...
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: file {
  73. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  74. // CHECK:STDOUT: .Core = imports.%Core
  75. // CHECK:STDOUT: .Defined = %Defined.decl
  76. // CHECK:STDOUT: .CallDefined = %CallDefined.decl
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: %Core.import = import Core
  79. // CHECK:STDOUT: %Defined.decl: %Defined.type = fn_decl @Defined [template = constants.%Defined] {
  80. // CHECK:STDOUT: %T.patt.loc4_12.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_12.2 (constants.%T.patt)]
  81. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4_12.1, runtime_param<invalid> [symbolic = %T.patt.loc4_12.2 (constants.%T.patt)]
  82. // CHECK:STDOUT: %x.patt: @Defined.%T.loc4_12.2 (%T) = binding_pattern x
  83. // CHECK:STDOUT: %x.param_patt: @Defined.%T.loc4_12.2 (%T) = value_param_pattern %x.patt, runtime_param0
  84. // CHECK:STDOUT: %return.patt: @Defined.%T.loc4_12.2 (%T) = return_slot_pattern
  85. // CHECK:STDOUT: %return.param_patt: @Defined.%T.loc4_12.2 (%T) = out_param_pattern %return.patt, runtime_param1
  86. // CHECK:STDOUT: } {
  87. // CHECK:STDOUT: %T.ref.loc4_25: type = name_ref T, %T.loc4_12.1 [symbolic = %T.loc4_12.2 (constants.%T)]
  88. // CHECK:STDOUT: %T.ref.loc4_31: type = name_ref T, %T.loc4_12.1 [symbolic = %T.loc4_12.2 (constants.%T)]
  89. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  90. // CHECK:STDOUT: %T.loc4_12.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_12.2 (constants.%T)]
  91. // CHECK:STDOUT: %x.param: @Defined.%T.loc4_12.2 (%T) = value_param runtime_param0
  92. // CHECK:STDOUT: %x: @Defined.%T.loc4_12.2 (%T) = bind_name x, %x.param
  93. // CHECK:STDOUT: %return.param: ref @Defined.%T.loc4_12.2 (%T) = out_param runtime_param1
  94. // CHECK:STDOUT: %return: ref @Defined.%T.loc4_12.2 (%T) = return_slot %return.param
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT: %CallDefined.decl: %CallDefined.type = fn_decl @CallDefined [template = constants.%CallDefined] {
  97. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  98. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
  99. // CHECK:STDOUT: } {
  100. // CHECK:STDOUT: %int_32.loc8: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  101. // CHECK:STDOUT: %int.make_type_signed.loc8: init type = call constants.%Int(%int_32.loc8) [template = constants.%i32]
  102. // CHECK:STDOUT: %.loc8_21.1: type = value_of_initializer %int.make_type_signed.loc8 [template = constants.%i32]
  103. // CHECK:STDOUT: %.loc8_21.2: type = converted %int.make_type_signed.loc8, %.loc8_21.1 [template = constants.%i32]
  104. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0
  105. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: generic fn @Defined(%T.loc4_12.1: type) {
  110. // CHECK:STDOUT: %T.loc4_12.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_12.2 (constants.%T)]
  111. // CHECK:STDOUT: %T.patt.loc4_12.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_12.2 (constants.%T.patt)]
  112. // CHECK:STDOUT:
  113. // CHECK:STDOUT: !definition:
  114. // CHECK:STDOUT:
  115. // CHECK:STDOUT: fn[%T.param_patt: type](%x.param_patt: @Defined.%T.loc4_12.2 (%T)) -> @Defined.%T.loc4_12.2 (%T) {
  116. // CHECK:STDOUT: !entry:
  117. // CHECK:STDOUT: %x.ref: @Defined.%T.loc4_12.2 (%T) = name_ref x, %x
  118. // CHECK:STDOUT: return %x.ref
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: fn @CallDefined() -> %i32 {
  123. // CHECK:STDOUT: !entry:
  124. // CHECK:STDOUT: %Defined.ref: %Defined.type = name_ref Defined, file.%Defined.decl [template = constants.%Defined]
  125. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.1]
  126. // CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  127. // CHECK:STDOUT: %int.make_type_signed.loc9: init type = call constants.%Int(%int_32.loc9) [template = constants.%i32]
  128. // CHECK:STDOUT: %.loc9_23.1: type = value_of_initializer %int.make_type_signed.loc9 [template = constants.%i32]
  129. // CHECK:STDOUT: %.loc9_23.2: type = converted %int.make_type_signed.loc9, %.loc9_23.1 [template = constants.%i32]
  130. // CHECK:STDOUT: %impl.elem0: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  131. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound]
  132. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.7(constants.%int_32) [template = constants.%Convert.specific_fn]
  133. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.2]
  134. // CHECK:STDOUT: %.loc9_20.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.2]
  135. // CHECK:STDOUT: %.loc9_20.2: %i32 = converted %int_0, %.loc9_20.1 [template = constants.%int_0.2]
  136. // CHECK:STDOUT: %Defined.specific_fn: <specific function> = specific_function %Defined.ref, @Defined(constants.%i32) [template = constants.%Defined.specific_fn]
  137. // CHECK:STDOUT: %Defined.call: init %i32 = call %Defined.specific_fn(%.loc9_20.2)
  138. // CHECK:STDOUT: %.loc9_27.1: %i32 = value_of_initializer %Defined.call
  139. // CHECK:STDOUT: %.loc9_27.2: %i32 = converted %Defined.call, %.loc9_27.1
  140. // CHECK:STDOUT: return %.loc9_27.2
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT:
  143. // CHECK:STDOUT: specific @Defined(constants.%T) {
  144. // CHECK:STDOUT: %T.loc4_12.2 => constants.%T
  145. // CHECK:STDOUT: %T.patt.loc4_12.2 => constants.%T
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT:
  148. // CHECK:STDOUT: specific @Defined(constants.%i32) {
  149. // CHECK:STDOUT: %T.loc4_12.2 => constants.%i32
  150. // CHECK:STDOUT: %T.patt.loc4_12.2 => constants.%i32
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: !definition:
  153. // CHECK:STDOUT: }
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: --- call_defined_late.carbon
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: constants {
  158. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  159. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  160. // CHECK:STDOUT: %Defined.type: type = fn_type @Defined [template]
  161. // CHECK:STDOUT: %Defined: %Defined.type = struct_value () [template]
  162. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  163. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  164. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  165. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  166. // CHECK:STDOUT: %CallDefined.type: type = fn_type @CallDefined [template]
  167. // CHECK:STDOUT: %CallDefined: %CallDefined.type = struct_value () [template]
  168. // CHECK:STDOUT: %int_0.1: Core.IntLiteral = int_value 0 [template]
  169. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @As(%i32) [template]
  170. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.7, @impl.5(%int_32) [template]
  171. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  172. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.14) [template]
  173. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0.1, %Convert.14 [template]
  174. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.7(%int_32) [template]
  175. // CHECK:STDOUT: %int_0.2: %i32 = int_value 0 [template]
  176. // CHECK:STDOUT: %Defined.specific_fn: <specific function> = specific_function %Defined, @Defined(%i32) [template]
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: imports {
  180. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  181. // CHECK:STDOUT: .Int = %import_ref.1
  182. // CHECK:STDOUT: .As = %import_ref.2
  183. // CHECK:STDOUT: import Core//prelude
  184. // CHECK:STDOUT: import Core//prelude/...
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: file {
  189. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  190. // CHECK:STDOUT: .Core = imports.%Core
  191. // CHECK:STDOUT: .Defined = %Defined.decl.loc4
  192. // CHECK:STDOUT: .CallDefined = %CallDefined.decl
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT: %Core.import = import Core
  195. // CHECK:STDOUT: %Defined.decl.loc4: %Defined.type = fn_decl @Defined [template = constants.%Defined] {
  196. // CHECK:STDOUT: %T.patt.loc10: type = symbolic_binding_pattern T, 0 [symbolic = constants.%T.patt]
  197. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc10, runtime_param<invalid> [symbolic = constants.%T.patt]
  198. // CHECK:STDOUT: %x.patt: %T = binding_pattern x
  199. // CHECK:STDOUT: %x.param_patt: %T = value_param_pattern %x.patt, runtime_param0
  200. // CHECK:STDOUT: %return.patt: %T = return_slot_pattern
  201. // CHECK:STDOUT: %return.param_patt: %T = out_param_pattern %return.patt, runtime_param1
  202. // CHECK:STDOUT: } {
  203. // CHECK:STDOUT: %T.ref.loc4_25: type = name_ref T, %T.loc4_12.1 [symbolic = %T.loc4_12.2 (constants.%T)]
  204. // CHECK:STDOUT: %T.ref.loc4_31: type = name_ref T, %T.loc4_12.1 [symbolic = %T.loc4_12.2 (constants.%T)]
  205. // CHECK:STDOUT: %T.param.loc4: type = value_param runtime_param<invalid>
  206. // CHECK:STDOUT: %T.loc4_12.1: type = bind_symbolic_name T, 0, %T.param.loc4 [symbolic = %T.loc4_12.2 (constants.%T)]
  207. // CHECK:STDOUT: %x.param.loc4: @Defined.%T.loc4_12.2 (%T) = value_param runtime_param0
  208. // CHECK:STDOUT: %x.loc4: @Defined.%T.loc4_12.2 (%T) = bind_name x, %x.param.loc4
  209. // CHECK:STDOUT: %return.param.loc4: ref @Defined.%T.loc4_12.2 (%T) = out_param runtime_param1
  210. // CHECK:STDOUT: %return.loc4: ref @Defined.%T.loc4_12.2 (%T) = return_slot %return.param.loc4
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT: %CallDefined.decl: %CallDefined.type = fn_decl @CallDefined [template = constants.%CallDefined] {
  213. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  214. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
  215. // CHECK:STDOUT: } {
  216. // CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  217. // CHECK:STDOUT: %int.make_type_signed.loc6: init type = call constants.%Int(%int_32.loc6) [template = constants.%i32]
  218. // CHECK:STDOUT: %.loc6_21.1: type = value_of_initializer %int.make_type_signed.loc6 [template = constants.%i32]
  219. // CHECK:STDOUT: %.loc6_21.2: type = converted %int.make_type_signed.loc6, %.loc6_21.1 [template = constants.%i32]
  220. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0
  221. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT: %Defined.decl.loc10: %Defined.type = fn_decl @Defined [template = constants.%Defined] {
  224. // CHECK:STDOUT: %T.patt.loc10: type = symbolic_binding_pattern T, 0 [symbolic = constants.%T.patt]
  225. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc10, runtime_param<invalid> [symbolic = constants.%T.patt]
  226. // CHECK:STDOUT: %x.patt: %T = binding_pattern x
  227. // CHECK:STDOUT: %x.param_patt: %T = value_param_pattern %x.patt, runtime_param0
  228. // CHECK:STDOUT: %return.patt: %T = return_slot_pattern
  229. // CHECK:STDOUT: %return.param_patt: %T = out_param_pattern %return.patt, runtime_param1
  230. // CHECK:STDOUT: } {
  231. // CHECK:STDOUT: %T.ref.loc10_25: type = name_ref T, %T.loc10 [symbolic = constants.%T]
  232. // CHECK:STDOUT: %T.ref.loc10_31: type = name_ref T, %T.loc10 [symbolic = constants.%T]
  233. // CHECK:STDOUT: %T.param.loc10: type = value_param runtime_param<invalid>
  234. // CHECK:STDOUT: %T.loc10: type = bind_symbolic_name T, 0, %T.param.loc10 [symbolic = constants.%T]
  235. // CHECK:STDOUT: %x.param.loc10: %T = value_param runtime_param0
  236. // CHECK:STDOUT: %x.loc10: %T = bind_name x, %x.param.loc10
  237. // CHECK:STDOUT: %return.param.loc10: ref %T = out_param runtime_param1
  238. // CHECK:STDOUT: %return.loc10: ref %T = return_slot %return.param.loc10
  239. // CHECK:STDOUT: }
  240. // CHECK:STDOUT: }
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: generic fn @Defined(%T.loc4_12.1: type) {
  243. // CHECK:STDOUT: %T.loc4_12.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_12.2 (constants.%T)]
  244. // CHECK:STDOUT: %T.patt.loc4: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4 (constants.%T.patt)]
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: !definition:
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: fn[%T.param_patt: type](%x.param_patt: %T) -> %T {
  249. // CHECK:STDOUT: !entry:
  250. // CHECK:STDOUT: %x.ref: @Defined.%T.loc4_12.2 (%T) = name_ref x, %x.loc10
  251. // CHECK:STDOUT: return %x.ref
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: fn @CallDefined() -> %i32 {
  256. // CHECK:STDOUT: !entry:
  257. // CHECK:STDOUT: %Defined.ref: %Defined.type = name_ref Defined, file.%Defined.decl.loc4 [template = constants.%Defined]
  258. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.1]
  259. // CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  260. // CHECK:STDOUT: %int.make_type_signed.loc7: init type = call constants.%Int(%int_32.loc7) [template = constants.%i32]
  261. // CHECK:STDOUT: %.loc7_23.1: type = value_of_initializer %int.make_type_signed.loc7 [template = constants.%i32]
  262. // CHECK:STDOUT: %.loc7_23.2: type = converted %int.make_type_signed.loc7, %.loc7_23.1 [template = constants.%i32]
  263. // CHECK:STDOUT: %impl.elem0: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  264. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound]
  265. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.7(constants.%int_32) [template = constants.%Convert.specific_fn]
  266. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.2]
  267. // CHECK:STDOUT: %.loc7_20.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.2]
  268. // CHECK:STDOUT: %.loc7_20.2: %i32 = converted %int_0, %.loc7_20.1 [template = constants.%int_0.2]
  269. // CHECK:STDOUT: %Defined.specific_fn: <specific function> = specific_function %Defined.ref, @Defined(constants.%i32) [template = constants.%Defined.specific_fn]
  270. // CHECK:STDOUT: %Defined.call: init %i32 = call %Defined.specific_fn(%.loc7_20.2)
  271. // CHECK:STDOUT: %.loc7_27.1: %i32 = value_of_initializer %Defined.call
  272. // CHECK:STDOUT: %.loc7_27.2: %i32 = converted %Defined.call, %.loc7_27.1
  273. // CHECK:STDOUT: return %.loc7_27.2
  274. // CHECK:STDOUT: }
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: specific @Defined(constants.%T) {
  277. // CHECK:STDOUT: %T.loc4_12.2 => constants.%T
  278. // CHECK:STDOUT: %T.patt.loc4 => constants.%T
  279. // CHECK:STDOUT: }
  280. // CHECK:STDOUT:
  281. // CHECK:STDOUT: specific @Defined(constants.%i32) {
  282. // CHECK:STDOUT: %T.loc4_12.2 => constants.%i32
  283. // CHECK:STDOUT: %T.patt.loc4 => constants.%i32
  284. // CHECK:STDOUT:
  285. // CHECK:STDOUT: !definition:
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: --- fail_call_undefined.carbon
  289. // CHECK:STDOUT:
  290. // CHECK:STDOUT: constants {
  291. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  292. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  293. // CHECK:STDOUT: %Undefined.type: type = fn_type @Undefined [template]
  294. // CHECK:STDOUT: %Undefined: %Undefined.type = struct_value () [template]
  295. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  296. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  297. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  298. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  299. // CHECK:STDOUT: %CallUndefined.type: type = fn_type @CallUndefined [template]
  300. // CHECK:STDOUT: %CallUndefined: %CallUndefined.type = struct_value () [template]
  301. // CHECK:STDOUT: %int_0.1: Core.IntLiteral = int_value 0 [template]
  302. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @As(%i32) [template]
  303. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.7, @impl.5(%int_32) [template]
  304. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  305. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.14) [template]
  306. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0.1, %Convert.14 [template]
  307. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.7(%int_32) [template]
  308. // CHECK:STDOUT: %int_0.2: %i32 = int_value 0 [template]
  309. // CHECK:STDOUT: %Undefined.specific_fn: <specific function> = specific_function %Undefined, @Undefined(%i32) [template]
  310. // CHECK:STDOUT: }
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: imports {
  313. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  314. // CHECK:STDOUT: .Int = %import_ref.1
  315. // CHECK:STDOUT: .As = %import_ref.2
  316. // CHECK:STDOUT: import Core//prelude
  317. // CHECK:STDOUT: import Core//prelude/...
  318. // CHECK:STDOUT: }
  319. // CHECK:STDOUT: }
  320. // CHECK:STDOUT:
  321. // CHECK:STDOUT: file {
  322. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  323. // CHECK:STDOUT: .Core = imports.%Core
  324. // CHECK:STDOUT: .Undefined = %Undefined.decl
  325. // CHECK:STDOUT: .CallUndefined = %CallUndefined.decl
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT: %Core.import = import Core
  328. // CHECK:STDOUT: %Undefined.decl: %Undefined.type = fn_decl @Undefined [template = constants.%Undefined] {
  329. // CHECK:STDOUT: %T.patt.loc4_14.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_14.2 (constants.%T.patt)]
  330. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4_14.1, runtime_param<invalid> [symbolic = %T.patt.loc4_14.2 (constants.%T.patt)]
  331. // CHECK:STDOUT: %x.patt: @Undefined.%T.loc4_14.2 (%T) = binding_pattern x
  332. // CHECK:STDOUT: %x.param_patt: @Undefined.%T.loc4_14.2 (%T) = value_param_pattern %x.patt, runtime_param0
  333. // CHECK:STDOUT: %return.patt: @Undefined.%T.loc4_14.2 (%T) = return_slot_pattern
  334. // CHECK:STDOUT: %return.param_patt: @Undefined.%T.loc4_14.2 (%T) = out_param_pattern %return.patt, runtime_param1
  335. // CHECK:STDOUT: } {
  336. // CHECK:STDOUT: %T.ref.loc4_27: type = name_ref T, %T.loc4_14.1 [symbolic = %T.loc4_14.2 (constants.%T)]
  337. // CHECK:STDOUT: %T.ref.loc4_33: type = name_ref T, %T.loc4_14.1 [symbolic = %T.loc4_14.2 (constants.%T)]
  338. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  339. // CHECK:STDOUT: %T.loc4_14.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_14.2 (constants.%T)]
  340. // CHECK:STDOUT: %x.param: @Undefined.%T.loc4_14.2 (%T) = value_param runtime_param0
  341. // CHECK:STDOUT: %x: @Undefined.%T.loc4_14.2 (%T) = bind_name x, %x.param
  342. // CHECK:STDOUT: %return.param: ref @Undefined.%T.loc4_14.2 (%T) = out_param runtime_param1
  343. // CHECK:STDOUT: %return: ref @Undefined.%T.loc4_14.2 (%T) = return_slot %return.param
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT: %CallUndefined.decl: %CallUndefined.type = fn_decl @CallUndefined [template = constants.%CallUndefined] {
  346. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  347. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
  348. // CHECK:STDOUT: } {
  349. // CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  350. // CHECK:STDOUT: %int.make_type_signed.loc6: init type = call constants.%Int(%int_32.loc6) [template = constants.%i32]
  351. // CHECK:STDOUT: %.loc6_23.1: type = value_of_initializer %int.make_type_signed.loc6 [template = constants.%i32]
  352. // CHECK:STDOUT: %.loc6_23.2: type = converted %int.make_type_signed.loc6, %.loc6_23.1 [template = constants.%i32]
  353. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0
  354. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  355. // CHECK:STDOUT: }
  356. // CHECK:STDOUT: }
  357. // CHECK:STDOUT:
  358. // CHECK:STDOUT: generic fn @Undefined(%T.loc4_14.1: type) {
  359. // CHECK:STDOUT: %T.loc4_14.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_14.2 (constants.%T)]
  360. // CHECK:STDOUT: %T.patt.loc4_14.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_14.2 (constants.%T.patt)]
  361. // CHECK:STDOUT:
  362. // CHECK:STDOUT: fn[%T.param_patt: type](%x.param_patt: @Undefined.%T.loc4_14.2 (%T)) -> @Undefined.%T.loc4_14.2 (%T);
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: fn @CallUndefined() -> %i32 {
  366. // CHECK:STDOUT: !entry:
  367. // CHECK:STDOUT: %Undefined.ref: %Undefined.type = name_ref Undefined, file.%Undefined.decl [template = constants.%Undefined]
  368. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.1]
  369. // CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  370. // CHECK:STDOUT: %int.make_type_signed.loc13: init type = call constants.%Int(%int_32.loc13) [template = constants.%i32]
  371. // CHECK:STDOUT: %.loc13_25.1: type = value_of_initializer %int.make_type_signed.loc13 [template = constants.%i32]
  372. // CHECK:STDOUT: %.loc13_25.2: type = converted %int.make_type_signed.loc13, %.loc13_25.1 [template = constants.%i32]
  373. // CHECK:STDOUT: %impl.elem0: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  374. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound]
  375. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.7(constants.%int_32) [template = constants.%Convert.specific_fn]
  376. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.2]
  377. // CHECK:STDOUT: %.loc13_22.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.2]
  378. // CHECK:STDOUT: %.loc13_22.2: %i32 = converted %int_0, %.loc13_22.1 [template = constants.%int_0.2]
  379. // CHECK:STDOUT: %Undefined.specific_fn: <specific function> = specific_function %Undefined.ref, @Undefined(constants.%i32) [template = constants.%Undefined.specific_fn]
  380. // CHECK:STDOUT: %Undefined.call: init %i32 = call %Undefined.specific_fn(%.loc13_22.2)
  381. // CHECK:STDOUT: %.loc13_29.1: %i32 = value_of_initializer %Undefined.call
  382. // CHECK:STDOUT: %.loc13_29.2: %i32 = converted %Undefined.call, %.loc13_29.1
  383. // CHECK:STDOUT: return %.loc13_29.2
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: specific @Undefined(constants.%T) {
  387. // CHECK:STDOUT: %T.loc4_14.2 => constants.%T
  388. // CHECK:STDOUT: %T.patt.loc4_14.2 => constants.%T
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: specific @Undefined(constants.%i32) {
  392. // CHECK:STDOUT: %T.loc4_14.2 => constants.%i32
  393. // CHECK:STDOUT: %T.patt.loc4_14.2 => constants.%i32
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT: