feat(backpassing): implements multi patterns

The main trick here was transforming Assignment
to contain `Vec<UntypedPattern, Option<Annotation>>`
in a field called patterns. This then meant that I
could remove the `pattern` and `annotation` field
from `Assignment`. The parser handles `=` and `<-`
just fine because in the future `=` with multi
patterns will mean some kind of optimization on tuples.
But, since we don't have that optimization yet, when
someone uses multi patterns with an `=` there will be an
error returned from the type checker right where `infer_seq`
looks for `backpassing`. From there the rest of the work
was in `Project::backpassing` where I only needed to rework
some things to work with a list of patterns instead of just one.
This commit is contained in:
rvcas
2024-03-11 18:23:17 -04:00
committed by Lucas
parent f02b9b0f0c
commit b6b52ba508
26 changed files with 592 additions and 292 deletions

View File

@@ -19,14 +19,18 @@ Module {
location: 23..26,
name: "bar",
},
pattern: Var {
location: 19..20,
name: "a",
},
patterns: [
(
Var {
location: 19..20,
name: "a",
},
None,
),
],
kind: Let {
backpassing: false,
},
annotation: None,
},
UInt {
location: 30..32,
@@ -59,14 +63,18 @@ Module {
location: 60..63,
name: "bar",
},
pattern: Var {
location: 56..57,
name: "a",
},
patterns: [
(
Var {
location: 56..57,
name: "a",
},
None,
),
],
kind: Let {
backpassing: false,
},
annotation: None,
},
UInt {
location: 67..69,
@@ -110,14 +118,18 @@ Module {
},
},
},
pattern: Var {
location: 93..94,
name: "a",
},
patterns: [
(
Var {
location: 93..94,
name: "a",
},
None,
),
],
kind: Let {
backpassing: false,
},
annotation: None,
},
doc: None,
location: 74..84,
@@ -157,14 +169,18 @@ Module {
},
location: 130..137,
},
pattern: Var {
location: 126..127,
name: "a",
},
patterns: [
(
Var {
location: 126..127,
name: "a",
},
None,
),
],
kind: Let {
backpassing: false,
},
annotation: None,
},
BinOp {
location: 141..153,

View File

@@ -24,14 +24,18 @@ Module {
],
preferred_format: Utf8String,
},
pattern: Var {
location: 17..18,
name: "x",
},
patterns: [
(
Var {
location: 17..18,
name: "x",
},
None,
),
],
kind: Let {
backpassing: false,
},
annotation: None,
},
Var {
location: 29..30,

View File

@@ -22,14 +22,18 @@ Module {
],
preferred_format: Utf8String,
},
pattern: Var {
location: 17..18,
name: "x",
},
patterns: [
(
Var {
location: 17..18,
name: "x",
},
None,
),
],
kind: Let {
backpassing: false,
},
annotation: None,
},
Var {
location: 27..28,