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
@@ -44,11 +44,19 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %y.patt: %i32 = binding_pattern y
// CHECK:STDOUT: %.loc16_3: %i32 = var_pattern %y.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %y.var: ref %i32 = var y
// CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var
// CHECK:STDOUT: %package.ref: <namespace> = name_ref package, package [template = package]
// CHECK:STDOUT: %x.ref: <error> = name_ref x, <error> [template = <error>]
// CHECK:STDOUT: assign %y.var, <error>
// CHECK:STDOUT: %.loc16_10: 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: }
// CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+46 -6
View File
@@ -72,9 +72,25 @@ fn Main() {
// CHECK:STDOUT: .y = %y
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x
// CHECK:STDOUT: %.loc4_1: %i32 = var_pattern %x.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %x.var: ref %i32 = var x
// CHECK:STDOUT: %.loc4_8: 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: %x: ref %i32 = bind_name x, %x.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %y.patt: %i32 = binding_pattern y
// CHECK:STDOUT: %.loc5_1: %i32 = var_pattern %y.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %y.var: ref %i32 = var y
// CHECK:STDOUT: %.loc5_8: type = splice_block %i32.loc5 [template = constants.%i32] {
// 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: }
// CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -131,28 +147,52 @@ fn Main() {
// CHECK:STDOUT: .Main = %Main.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x
// CHECK:STDOUT: %.loc4_1: %i32 = var_pattern %x.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %x.var: ref %i32 = var x
// CHECK:STDOUT: %.loc4_8: 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: }
// CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var
// CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x
// CHECK:STDOUT: %.loc7_3.1: %i32 = var_pattern %x.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %x.var: ref %i32 = var x
// CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
// 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_1, %impl.elem0 [template = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c]
// CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_1) [template = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc7: init %i32 = converted %int_1, %int.convert_checked [template = constants.%int_1.5d2]
// CHECK:STDOUT: assign %x.var, %.loc7
// CHECK:STDOUT: %.loc7_3.2: init %i32 = converted %int_1, %int.convert_checked [template = constants.%int_1.5d2]
// CHECK:STDOUT: assign %x.var, %.loc7_3.2
// CHECK:STDOUT: %.loc7_10: type = splice_block %i32.loc7 [template = constants.%i32] {
// CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %y.patt: %i32 = binding_pattern y
// CHECK:STDOUT: %.loc9_3: %i32 = var_pattern %y.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %y.var: ref %i32 = var y
// CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var
// CHECK:STDOUT: %package.ref: <namespace> = name_ref package, package [template = package]
// CHECK:STDOUT: %x.ref: ref %i32 = name_ref x, file.%x
// CHECK:STDOUT: %.loc9: %i32 = bind_value %x.ref
// CHECK:STDOUT: assign %y.var, %.loc9
// CHECK:STDOUT: %.loc9_23: %i32 = bind_value %x.ref
// CHECK:STDOUT: assign %y.var, %.loc9_23
// CHECK:STDOUT: %.loc9_10: type = splice_block %i32.loc9 [template = constants.%i32] {
// CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT: