Model var as a pattern operator (#4720)

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Geoff Romer
2025-01-17 17:51:34 +00:00
committed by GitHub
co-authored by Richard Smith
parent 6572da7314
commit 13434f0e8a
510 changed files with 11819 additions and 3352 deletions
+13 -5
View File
@@ -50,8 +50,8 @@ fn F() -> i32 {
// CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
@@ -59,15 +59,23 @@ fn F() -> i32 {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n
// CHECK:STDOUT: %.loc12_3.1: %i32 = var_pattern %n.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %n.var: ref %i32 = var n
// CHECK:STDOUT: %n: ref %i32 = bind_name n, %n.var
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6]
// CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
// CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.6a9]
// CHECK:STDOUT: %.loc12: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.6a9]
// CHECK:STDOUT: assign %n.var, %.loc12
// CHECK:STDOUT: %.loc12_3.2: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.6a9]
// CHECK:STDOUT: assign %n.var, %.loc12_3.2
// CHECK:STDOUT: %.loc12_10: type = splice_block %i32.loc12 [template = constants.%i32] {
// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %n: ref %i32 = bind_name n, %n.var
// CHECK:STDOUT: %n.ref: ref %i32 = name_ref n, %n
// CHECK:STDOUT: %addr.loc13_13: %ptr = addr_of %n.ref
// CHECK:STDOUT: %.loc13_12: ref %i32 = deref %addr.loc13_13
+87 -15
View File
@@ -44,6 +44,7 @@ fn F() {
// CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [template]
// CHECK:STDOUT: %struct: %struct_type.a.b.501 = struct_value (%int_1.5d2, %int_2.ef8) [template]
// CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [template]
// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template]
// CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template]
// CHECK:STDOUT: %tuple.type.f94: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [template]
// CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%int_1.5d2, %int_2.ef8) [template]
@@ -70,8 +71,11 @@ fn F() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %s.patt: %struct_type.a.b.501 = binding_pattern s
// CHECK:STDOUT: %.loc12_3.1: %struct_type.a.b.501 = var_pattern %s.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %s.var: ref %struct_type.a.b.501 = var s
// CHECK:STDOUT: %s: ref %struct_type.a.b.501 = bind_name s, %s.var
// CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc12: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc12_46.1: %struct_type.a.b.cfd = struct_literal (%int_1.loc12, %int_2.loc12)
@@ -90,27 +94,68 @@ fn F() {
// CHECK:STDOUT: %.loc12_46.6: ref %i32 = struct_access %s.var, element1
// CHECK:STDOUT: %.loc12_46.7: init %i32 = initialize_from %.loc12_46.5 to %.loc12_46.6 [template = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc12_46.8: init %struct_type.a.b.501 = struct_init (%.loc12_46.4, %.loc12_46.7) to %s.var [template = constants.%struct]
// CHECK:STDOUT: %.loc12_47: init %struct_type.a.b.501 = converted %.loc12_46.1, %.loc12_46.8 [template = constants.%struct]
// CHECK:STDOUT: assign %s.var, %.loc12_47
// CHECK:STDOUT: %.loc12_3.2: init %struct_type.a.b.501 = converted %.loc12_46.1, %.loc12_46.8 [template = constants.%struct]
// CHECK:STDOUT: assign %s.var, %.loc12_3.2
// CHECK:STDOUT: %.loc12_27: type = splice_block %struct_type.a.b.loc12 [template = constants.%struct_type.a.b.501] {
// CHECK:STDOUT: %int_32.loc12_15: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc12_15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %int_32.loc12_24: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc12_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %struct_type.a.b.loc12: type = struct_type {.a: %i32, .b: %i32} [template = constants.%struct_type.a.b.501]
// CHECK:STDOUT: }
// CHECK:STDOUT: %s: ref %struct_type.a.b.501 = bind_name s, %s.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %p.patt: %ptr.3ee = binding_pattern p
// CHECK:STDOUT: %.loc14_3: %ptr.3ee = var_pattern %p.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %p.var: ref %ptr.3ee = var p
// CHECK:STDOUT: %p: ref %ptr.3ee = bind_name p, %p.var
// CHECK:STDOUT: %s.ref.loc14: ref %struct_type.a.b.501 = name_ref s, %s
// CHECK:STDOUT: %addr.loc14: %ptr.3ee = addr_of %s.ref.loc14
// CHECK:STDOUT: assign %p.var, %addr.loc14
// CHECK:STDOUT: %.loc14_28: type = splice_block %ptr.loc14 [template = constants.%ptr.3ee] {
// CHECK:STDOUT: %int_32.loc14_15: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc14_15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %int_32.loc14_24: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc14_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %struct_type.a.b.loc14: type = struct_type {.a: %i32, .b: %i32} [template = constants.%struct_type.a.b.501]
// CHECK:STDOUT: %ptr.loc14: type = ptr_type %struct_type.a.b.501 [template = constants.%ptr.3ee]
// CHECK:STDOUT: }
// CHECK:STDOUT: %p: ref %ptr.3ee = bind_name p, %p.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %q.patt: %ptr.235 = binding_pattern q
// CHECK:STDOUT: %.loc15_3: %ptr.235 = var_pattern %q.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %q.var: ref %ptr.235 = var q
// CHECK:STDOUT: %q: ref %ptr.235 = bind_name q, %q.var
// CHECK:STDOUT: %s.ref.loc15: ref %struct_type.a.b.501 = name_ref s, %s
// CHECK:STDOUT: %.loc15: ref %i32 = struct_access %s.ref.loc15, element0
// CHECK:STDOUT: %addr.loc15: %ptr.235 = addr_of %.loc15
// CHECK:STDOUT: %.loc15_19: ref %i32 = struct_access %s.ref.loc15, element0
// CHECK:STDOUT: %addr.loc15: %ptr.235 = addr_of %.loc15_19
// CHECK:STDOUT: assign %q.var, %addr.loc15
// CHECK:STDOUT: %.loc15_13: type = splice_block %ptr.loc15 [template = constants.%ptr.235] {
// CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %ptr.loc15: type = ptr_type %i32 [template = constants.%ptr.235]
// CHECK:STDOUT: }
// CHECK:STDOUT: %q: ref %ptr.235 = bind_name q, %q.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %r.patt: %ptr.235 = binding_pattern r
// CHECK:STDOUT: %.loc16_3: %ptr.235 = var_pattern %r.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %r.var: ref %ptr.235 = var r
// CHECK:STDOUT: %r: ref %ptr.235 = bind_name r, %r.var
// CHECK:STDOUT: %s.ref.loc16: ref %struct_type.a.b.501 = name_ref s, %s
// CHECK:STDOUT: %.loc16: ref %i32 = struct_access %s.ref.loc16, element1
// CHECK:STDOUT: %addr.loc16: %ptr.235 = addr_of %.loc16
// CHECK:STDOUT: %.loc16_19: ref %i32 = struct_access %s.ref.loc16, element1
// CHECK:STDOUT: %addr.loc16: %ptr.235 = addr_of %.loc16_19
// CHECK:STDOUT: assign %r.var, %addr.loc16
// CHECK:STDOUT: %.loc16_13: type = splice_block %ptr.loc16 [template = constants.%ptr.235] {
// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %ptr.loc16: type = ptr_type %i32 [template = constants.%ptr.235]
// CHECK:STDOUT: }
// CHECK:STDOUT: %r: ref %ptr.235 = bind_name r, %r.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %t.patt: %tuple.type.d07 = binding_pattern t
// CHECK:STDOUT: %.loc18_3.1: %tuple.type.d07 = var_pattern %t.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %t.var: ref %tuple.type.d07 = var t
// CHECK:STDOUT: %t: ref %tuple.type.d07 = bind_name t, %t.var
// CHECK:STDOUT: %int_1.loc18: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc18: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc18_28.1: %tuple.type.f94 = tuple_literal (%int_1.loc18, %int_2.loc18)
@@ -129,22 +174,49 @@ fn F() {
// CHECK:STDOUT: %tuple.elem1.loc18: ref %i32 = tuple_access %t.var, element1
// CHECK:STDOUT: %.loc18_28.5: init %i32 = initialize_from %.loc18_28.4 to %tuple.elem1.loc18 [template = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc18_28.6: init %tuple.type.d07 = tuple_init (%.loc18_28.3, %.loc18_28.5) to %t.var [template = constants.%tuple]
// CHECK:STDOUT: %.loc18_29: init %tuple.type.d07 = converted %.loc18_28.1, %.loc18_28.6 [template = constants.%tuple]
// CHECK:STDOUT: assign %t.var, %.loc18_29
// CHECK:STDOUT: %.loc18_3.2: init %tuple.type.d07 = converted %.loc18_28.1, %.loc18_28.6 [template = constants.%tuple]
// CHECK:STDOUT: assign %t.var, %.loc18_3.2
// CHECK:STDOUT: %.loc18_19.1: type = splice_block %.loc18_19.3 [template = constants.%tuple.type.d07] {
// CHECK:STDOUT: %int_32.loc18_11: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc18_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %int_32.loc18_16: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc18_16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %.loc18_19.2: %tuple.type.24b = tuple_literal (%i32.loc18_11, %i32.loc18_16)
// CHECK:STDOUT: %.loc18_19.3: type = converted %.loc18_19.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07]
// CHECK:STDOUT: }
// CHECK:STDOUT: %t: ref %tuple.type.d07 = bind_name t, %t.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %t0.patt: %ptr.235 = binding_pattern t0
// CHECK:STDOUT: %.loc19_3: %ptr.235 = var_pattern %t0.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %t0.var: ref %ptr.235 = var t0
// CHECK:STDOUT: %t0: ref %ptr.235 = bind_name t0, %t0.var
// CHECK:STDOUT: %t.ref.loc19: ref %tuple.type.d07 = name_ref t, %t
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
// CHECK:STDOUT: %tuple.elem0.loc19: ref %i32 = tuple_access %t.ref.loc19, element0
// CHECK:STDOUT: %addr.loc19: %ptr.235 = addr_of %tuple.elem0.loc19
// CHECK:STDOUT: assign %t0.var, %addr.loc19
// CHECK:STDOUT: %.loc19_14: type = splice_block %ptr.loc19 [template = constants.%ptr.235] {
// CHECK:STDOUT: %int_32.loc19: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %ptr.loc19: type = ptr_type %i32 [template = constants.%ptr.235]
// CHECK:STDOUT: }
// CHECK:STDOUT: %t0: ref %ptr.235 = bind_name t0, %t0.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %t1.patt: %ptr.235 = binding_pattern t1
// CHECK:STDOUT: %.loc20_3: %ptr.235 = var_pattern %t1.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %t1.var: ref %ptr.235 = var t1
// CHECK:STDOUT: %t1: ref %ptr.235 = bind_name t1, %t1.var
// CHECK:STDOUT: %t.ref.loc20: ref %tuple.type.d07 = name_ref t, %t
// CHECK:STDOUT: %int_1.loc20: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
// CHECK:STDOUT: %tuple.elem1.loc20: ref %i32 = tuple_access %t.ref.loc20, element1
// CHECK:STDOUT: %addr.loc20: %ptr.235 = addr_of %tuple.elem1.loc20
// CHECK:STDOUT: assign %t1.var, %addr.loc20
// CHECK:STDOUT: %.loc20_14: type = splice_block %ptr.loc20 [template = constants.%ptr.235] {
// CHECK:STDOUT: %int_32.loc20: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc20: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %ptr.loc20: type = ptr_type %i32 [template = constants.%ptr.235]
// CHECK:STDOUT: }
// CHECK:STDOUT: %t1: ref %ptr.235 = bind_name t1, %t1.var
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+9 -5
View File
@@ -75,7 +75,11 @@ fn Foo(ptr: C*) {
// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [template = constants.%C]
// CHECK:STDOUT: %self: %C = bind_name self, %self.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc13: %C.elem = field_decl field, element0 [template]
// CHECK:STDOUT: %.loc13_12: %C.elem = field_decl field, element0 [template]
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %.loc13_3: %C.elem = var_pattern %.loc13_12
// CHECK:STDOUT: }
// CHECK:STDOUT: %.var: ref %C.elem = var <invalid>
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.field [template = constants.%complete_type]
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT: }
@@ -98,19 +102,19 @@ fn Foo(ptr: C*) {
// CHECK:STDOUT: %Member.call.loc18: init %empty_tuple.type = call %Member.bound.loc18(%.loc18_6.2)
// CHECK:STDOUT: %ptr.ref.loc20: %ptr.019 = name_ref ptr, %ptr.loc16_8
// CHECK:STDOUT: %.loc20_4: ref %C = deref %ptr.ref.loc20
// CHECK:STDOUT: %field.ref.loc20: %C.elem = name_ref field, @C.%.loc13 [template = @C.%.loc13]
// CHECK:STDOUT: %field.ref.loc20: %C.elem = name_ref field, @C.%.loc13_12 [template = @C.%.loc13_12]
// CHECK:STDOUT: %.loc20_9: ref %ptr.019 = class_element_access %.loc20_4, element0
// CHECK:STDOUT: %ptr.ref.loc21: %ptr.019 = name_ref ptr, %ptr.loc16_8
// CHECK:STDOUT: %.loc21_6.1: ref %C = deref %ptr.ref.loc21
// CHECK:STDOUT: %field.ref.loc21: %C.elem = name_ref field, @C.%.loc13 [template = @C.%.loc13]
// CHECK:STDOUT: %field.ref.loc21: %C.elem = name_ref field, @C.%.loc13_12 [template = @C.%.loc13_12]
// CHECK:STDOUT: %.loc21_6.2: ref %ptr.019 = class_element_access %.loc21_6.1, element0
// CHECK:STDOUT: %ptr.ref.loc23: %ptr.019 = name_ref ptr, %ptr.loc16_8
// CHECK:STDOUT: %.loc23_6.1: ref %C = deref %ptr.ref.loc23
// CHECK:STDOUT: %field.ref.loc23_6: %C.elem = name_ref field, @C.%.loc13 [template = @C.%.loc13]
// CHECK:STDOUT: %field.ref.loc23_6: %C.elem = name_ref field, @C.%.loc13_12 [template = @C.%.loc13_12]
// CHECK:STDOUT: %.loc23_6.2: ref %ptr.019 = class_element_access %.loc23_6.1, element0
// CHECK:STDOUT: %.loc23_6.3: %ptr.019 = bind_value %.loc23_6.2
// CHECK:STDOUT: %.loc23_13.1: ref %C = deref %.loc23_6.3
// CHECK:STDOUT: %field.ref.loc23_13: %C.elem = name_ref field, @C.%.loc13 [template = @C.%.loc13]
// CHECK:STDOUT: %field.ref.loc23_13: %C.elem = name_ref field, @C.%.loc13_12 [template = @C.%.loc13_12]
// CHECK:STDOUT: %.loc23_13.2: ref %ptr.019 = class_element_access %.loc23_13.1, element0
// CHECK:STDOUT: return
// CHECK:STDOUT: }
+23 -6
View File
@@ -52,8 +52,8 @@ fn F() -> i32 {
// CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
@@ -61,20 +61,37 @@ fn F() -> i32 {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n
// CHECK:STDOUT: %.loc12_3.1: %i32 = var_pattern %n.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %n.var: ref %i32 = var n
// CHECK:STDOUT: %n: ref %i32 = bind_name n, %n.var
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6]
// CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
// CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.6a9]
// CHECK:STDOUT: %.loc12: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.6a9]
// CHECK:STDOUT: assign %n.var, %.loc12
// CHECK:STDOUT: %.loc12_3.2: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.6a9]
// CHECK:STDOUT: assign %n.var, %.loc12_3.2
// CHECK:STDOUT: %.loc12_10: type = splice_block %i32.loc12 [template = constants.%i32] {
// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %n: ref %i32 = bind_name n, %n.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %p.patt: %ptr = binding_pattern p
// CHECK:STDOUT: %.loc13_3: %ptr = var_pattern %p.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %p.var: ref %ptr = var p
// CHECK:STDOUT: %p: ref %ptr = bind_name p, %p.var
// CHECK:STDOUT: %n.ref: ref %i32 = name_ref n, %n
// CHECK:STDOUT: %addr: %ptr = addr_of %n.ref
// CHECK:STDOUT: assign %p.var, %addr
// CHECK:STDOUT: %.loc13_13: type = splice_block %ptr [template = constants.%ptr] {
// CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr]
// CHECK:STDOUT: }
// CHECK:STDOUT: %p: ref %ptr = bind_name p, %p.var
// CHECK:STDOUT: %p.ref: ref %ptr = name_ref p, %p
// CHECK:STDOUT: %.loc15_11: %ptr = bind_value %p.ref
// CHECK:STDOUT: %.loc15_10.1: ref %i32 = deref %.loc15_11
@@ -195,9 +195,9 @@ fn AddressOfParam(param: i32) {
// CHECK:STDOUT: %param.param_patt: %i32 = value_param_pattern %param.patt, runtime_param0
// CHECK:STDOUT: } {
// CHECK:STDOUT: %param.param: %i32 = value_param runtime_param0
// CHECK:STDOUT: %.loc95: type = splice_block %i32 [template = constants.%i32] {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %.loc95: type = splice_block %i32.loc95 [template = constants.%i32] {
// CHECK:STDOUT: %int_32.loc95: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc95: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %param: %i32 = bind_name param, %param.param
// CHECK:STDOUT: }
@@ -288,11 +288,20 @@ fn AddressOfParam(param: i32) {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @AddressOfParam(%param.param_patt: %i32) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %param_addr.patt: %ptr.235 = binding_pattern param_addr
// CHECK:STDOUT: %.loc100_3: %ptr.235 = var_pattern %param_addr.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %param_addr.var: ref %ptr.235 = var param_addr
// CHECK:STDOUT: %param_addr: ref %ptr.235 = bind_name param_addr, %param_addr.var
// CHECK:STDOUT: %param.ref: %i32 = name_ref param, %param
// CHECK:STDOUT: %addr: %ptr.235 = addr_of <error> [template = <error>]
// CHECK:STDOUT: assign %param_addr.var, %addr
// CHECK:STDOUT: %.loc100_22: type = splice_block %ptr [template = constants.%ptr.235] {
// CHECK:STDOUT: %int_32.loc100: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc100: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr.235]
// CHECK:STDOUT: }
// CHECK:STDOUT: %param_addr: ref %ptr.235 = bind_name param_addr, %param_addr.var
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+18 -4
View File
@@ -37,21 +37,35 @@ let n2: i32 = undeclared->foo;
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .n = @__global_init.%n
// CHECK:STDOUT: .n2 = @__global_init.%n2
// CHECK:STDOUT: .n = %n
// CHECK:STDOUT: .n2 = %n2
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc15: type = splice_block %i32.loc15 [template = constants.%i32] {
// CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %n: %i32 = bind_name n, <error>
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %n2.patt: %i32 = binding_pattern n2
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc20: type = splice_block %i32.loc20 [template = constants.%i32] {
// CHECK:STDOUT: %int_32.loc20: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc20: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %n2: %i32 = bind_name n2, <error>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %undeclared.ref.loc15: <error> = name_ref undeclared, <error> [template = <error>]
// CHECK:STDOUT: %.loc15: ref <error> = deref <error>
// CHECK:STDOUT: %n: %i32 = bind_name n, <error>
// CHECK:STDOUT: %undeclared.ref.loc20: <error> = name_ref undeclared, <error> [template = <error>]
// CHECK:STDOUT: %.loc20: ref <error> = deref <error>
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [template = <error>]
// CHECK:STDOUT: %n2: %i32 = bind_name n2, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+23 -2
View File
@@ -25,6 +25,8 @@ var p2: i32->foo;
// CHECK:STDOUT: --- fail_deref_type.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
@@ -42,9 +44,28 @@ var p2: i32->foo;
// CHECK:STDOUT: .p2 = %p2
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %p.patt: <error> = binding_pattern p
// CHECK:STDOUT: %.loc18_1: <error> = var_pattern %p.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %p.var: ref <error> = var p
// CHECK:STDOUT: %p: ref <error> = bind_name p, %p.var
// CHECK:STDOUT: %.1: <error> = splice_block <error> [template = <error>] {
// CHECK:STDOUT: %int_32.loc18: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc18: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %.loc18_8: ref <error> = deref %i32.loc18
// CHECK:STDOUT: }
// CHECK:STDOUT: %p: <error> = bind_name p, <error>
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %p2.patt: <error> = binding_pattern p2
// CHECK:STDOUT: %.loc23_1: <error> = var_pattern %p2.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %p2.var: ref <error> = var p2
// CHECK:STDOUT: %p2: ref <error> = bind_name p2, %p2.var
// CHECK:STDOUT: %.2: <error> = splice_block <error> [template = <error>] {
// CHECK:STDOUT: %int_32.loc23: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %.loc23_12: ref <error> = deref %i32.loc23
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [template = <error>]
// CHECK:STDOUT: }
// CHECK:STDOUT: %p2: <error> = bind_name p2, <error>
// CHECK:STDOUT: }
// CHECK:STDOUT:
+26
View File
@@ -53,9 +53,26 @@ var a: i32* = a_ref;
// CHECK:STDOUT: .a_ref = %a_ref
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a_orig.patt: %i32 = binding_pattern a_orig
// CHECK:STDOUT: %.loc4_1: %i32 = var_pattern %a_orig.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %a_orig.var: ref %i32 = var a_orig
// CHECK:STDOUT: %.loc4_13: type = splice_block %i32.loc4 [template = constants.%i32] {
// CHECK:STDOUT: %int_32.loc4: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc4: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a_orig: ref %i32 = bind_name a_orig, %a_orig.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a_ref.patt: %ptr = binding_pattern a_ref
// CHECK:STDOUT: %.loc5_1: %ptr = var_pattern %a_ref.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %a_ref.var: ref %ptr = var a_ref
// CHECK:STDOUT: %.loc5_15: type = splice_block %ptr [template = constants.%ptr] {
// CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc5: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a_ref: ref %ptr = bind_name a_ref, %a_ref.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -102,7 +119,16 @@ var a: i32* = a_ref;
// CHECK:STDOUT: %Implicit.import = import Implicit
// CHECK:STDOUT: %default.import = import <invalid>
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: %ptr = binding_pattern a
// CHECK:STDOUT: %.loc4_1: %ptr = var_pattern %a.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref %ptr = var a
// CHECK:STDOUT: %.loc4_11: type = splice_block %ptr [template = constants.%ptr] {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: ref %ptr = bind_name a, %a.var
// CHECK:STDOUT: }
// CHECK:STDOUT: