feat: parser and check fixes

- do not erase sequences if the sole expression is an assignment
- emit parse error if an assignment is assigned to an assignment
- do not allow assignments in logical op chains
This commit is contained in:
rvcas
2024-01-19 14:32:21 -05:00
parent 8a90e9eda0
commit 25a837ab3f
7 changed files with 105 additions and 6 deletions

View File

@@ -109,4 +109,15 @@ mod tests {
"#
);
}
#[test]
fn function_assignment_only() {
assert_definition!(
r#"
fn run() {
let x = 1 + 1
}
"#
);
}
}

View File

@@ -0,0 +1,44 @@
---
source: crates/aiken-lang/src/parser/definition/function.rs
description: "Code:\n\nfn run() {\n let x = 1 + 1\n}\n"
---
Fn(
Function {
arguments: [],
body: Assignment {
location: 13..26,
value: BinOp {
location: 21..26,
name: AddInt,
left: UInt {
location: 21..22,
value: "1",
base: Decimal {
numeric_underscore: false,
},
},
right: UInt {
location: 25..26,
value: "1",
base: Decimal {
numeric_underscore: false,
},
},
},
pattern: Var {
location: 17..18,
name: "x",
},
kind: Let,
annotation: None,
},
doc: None,
location: 0..8,
name: "run",
public: false,
return_annotation: None,
return_type: (),
end_position: 27,
can_error: true,
},
)