fix: expect on tuples from data now checks for no more items after the last
This commit is contained in:
parent
8e75007a5f
commit
1bcc9e8524
|
@ -675,7 +675,8 @@ impl<'a> CodeGenerator<'a> {
|
|||
name != "_"
|
||||
} else {
|
||||
true
|
||||
}
|
||||
},
|
||||
"No discard expressions or let bindings should be in the tree at this point."
|
||||
);
|
||||
if props.value_type.is_data() && props.kind.is_expect() && !tipo.is_data() {
|
||||
value = AirTree::cast_from_data(value, tipo.clone());
|
||||
|
@ -689,25 +690,23 @@ impl<'a> CodeGenerator<'a> {
|
|||
location,
|
||||
..
|
||||
} => {
|
||||
if props.kind.is_expect() {
|
||||
let name = format!(
|
||||
"__expected_by_{}_span_{}_{}",
|
||||
expected_int, location.start, location.end
|
||||
);
|
||||
assert!(props.kind.is_expect());
|
||||
|
||||
let assignment = AirTree::let_assignment(&name, value);
|
||||
let name = format!(
|
||||
"__expected_by_{}_span_{}_{}",
|
||||
expected_int, location.start, location.end
|
||||
);
|
||||
|
||||
let expect = AirTree::binop(
|
||||
BinOp::Eq,
|
||||
bool(),
|
||||
AirTree::int(expected_int),
|
||||
AirTree::local_var(name, int()),
|
||||
int(),
|
||||
);
|
||||
AirTree::assert_bool(true, assignment.hoist_over(expect))
|
||||
} else {
|
||||
unreachable!("Code Gen should never reach here")
|
||||
}
|
||||
let assignment = AirTree::let_assignment(&name, value);
|
||||
|
||||
let expect = AirTree::binop(
|
||||
BinOp::Eq,
|
||||
bool(),
|
||||
AirTree::int(expected_int),
|
||||
AirTree::local_var(name, int()),
|
||||
int(),
|
||||
);
|
||||
AirTree::assert_bool(true, assignment.hoist_over(expect))
|
||||
}
|
||||
Pattern::Var { name, .. } => {
|
||||
if props.full_check {
|
||||
|
@ -1368,7 +1367,7 @@ impl<'a> CodeGenerator<'a> {
|
|||
let tuple_access = AirTree::tuple_access(
|
||||
tuple_index_names,
|
||||
tipo.clone(),
|
||||
false,
|
||||
true,
|
||||
AirTree::local_var(tuple_name, tipo.clone()),
|
||||
);
|
||||
|
||||
|
|
|
@ -567,8 +567,8 @@ mod tests {
|
|||
"$ref": "#/definitions/Tuple$Int_Int_Int"
|
||||
}
|
||||
},
|
||||
"compiledCode": "585f01000032323232322223232323253330084a22930b191919191924c6eb4c038004c038008dd6980600098060011bad300a0013758008646eb8c020008dd69803000991919bb03009002300900130090013758006ae6955ceaab9e5742ae881",
|
||||
"hash": "91b63a27e3a0523a1ccef050cb77537ea0b5e3da2e00a05f7db07db2",
|
||||
"compiledCode": "58a8010000323232323232322223232323253330084a22930b1919191919299980818090010a4c2a6601a921334c6973742f5475706c652f436f6e73747220636f6e7461696e73206d6f7265206974656d73207468616e2065787065637465640016375a602000260200046eb4c038004c038008dd698060009bac00432375c60120046eb4c01c004c8c8cdd81805801180580098058009bac0035734ae7155ceaab9e5573eae855d101",
|
||||
"hash": "d21ff2a6ebd64fb9c3bbfe555b7db490a878566185be79241fc22b1e",
|
||||
"definitions": {
|
||||
"ByteArray": {
|
||||
"dataType": "bytes"
|
||||
|
|
Loading…
Reference in New Issue