Merge pull request #1120 from aiken-lang/avoid-adjacent-sequence-fusions
Fix adjacent sequence collapse in parser
This commit is contained in:
commit
3fa25fecfa
|
@ -17,6 +17,7 @@
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- **aiken-lang**: Formatter was removing comments from function type annotation args @rvcas
|
- **aiken-lang**: Formatter was removing comments from function type annotation args @rvcas
|
||||||
|
- **aiken-lang**: Parser wrongly merged two adjacent sequences together, effectively fusioning scopes. @KtorZ
|
||||||
- **aiken-lang**: Fix hint when suggesting to use named fields, wrongly suggesting args in lexicographical order instead of definition order. @KtorZ
|
- **aiken-lang**: Fix hint when suggesting to use named fields, wrongly suggesting args in lexicographical order instead of definition order. @KtorZ
|
||||||
|
|
||||||
## v1.1.13 - 2025-02-26
|
## v1.1.13 - 2025-02-26
|
||||||
|
|
|
@ -1405,23 +1405,10 @@ impl UntypedExpr {
|
||||||
};
|
};
|
||||||
|
|
||||||
match (self.clone(), next.clone()) {
|
match (self.clone(), next.clone()) {
|
||||||
(
|
(left @ Self::Sequence { .. }, right @ Self::Sequence { .. }) => Self::Sequence {
|
||||||
Self::Sequence {
|
location,
|
||||||
expressions: mut current_expressions,
|
expressions: vec![left, right],
|
||||||
..
|
},
|
||||||
},
|
|
||||||
Self::Sequence {
|
|
||||||
expressions: mut next_expressions,
|
|
||||||
..
|
|
||||||
},
|
|
||||||
) => {
|
|
||||||
current_expressions.append(&mut next_expressions);
|
|
||||||
|
|
||||||
Self::Sequence {
|
|
||||||
location,
|
|
||||||
expressions: current_expressions,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(
|
(
|
||||||
_,
|
_,
|
||||||
Self::Sequence {
|
Self::Sequence {
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub fn parser(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::assert_expr;
|
use crate::{assert_definition, assert_expr};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn block_let() {
|
fn block_let() {
|
||||||
|
@ -54,4 +54,35 @@ mod tests {
|
||||||
"#
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sequence_then_expr() {
|
||||||
|
assert_definition!(
|
||||||
|
r#"
|
||||||
|
test foo() {
|
||||||
|
{
|
||||||
|
let a = Void
|
||||||
|
a
|
||||||
|
}
|
||||||
|
True
|
||||||
|
}
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sequence_then_sequence() {
|
||||||
|
assert_definition!(
|
||||||
|
r#"
|
||||||
|
test foo() {
|
||||||
|
{
|
||||||
|
let a = Void
|
||||||
|
a
|
||||||
|
}
|
||||||
|
let _ = True
|
||||||
|
True
|
||||||
|
}
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
---
|
||||||
|
source: crates/aiken-lang/src/parser/expr/block.rs
|
||||||
|
description: "Code:\n\ntest foo() {\n {\n let a = Void\n a\n }\n True\n}\n"
|
||||||
|
---
|
||||||
|
Test(
|
||||||
|
Function {
|
||||||
|
arguments: [],
|
||||||
|
body: Sequence {
|
||||||
|
location: 38..50,
|
||||||
|
expressions: [
|
||||||
|
Sequence {
|
||||||
|
location: 21..39,
|
||||||
|
expressions: [
|
||||||
|
Assignment {
|
||||||
|
location: 21..33,
|
||||||
|
value: Var {
|
||||||
|
location: 29..33,
|
||||||
|
name: "Void",
|
||||||
|
},
|
||||||
|
patterns: [
|
||||||
|
AssignmentPattern {
|
||||||
|
pattern: Var {
|
||||||
|
location: 25..26,
|
||||||
|
name: "a",
|
||||||
|
},
|
||||||
|
annotation: None,
|
||||||
|
location: 25..26,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
kind: Let {
|
||||||
|
backpassing: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Var {
|
||||||
|
location: 38..39,
|
||||||
|
name: "a",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
Var {
|
||||||
|
location: 46..50,
|
||||||
|
name: "True",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
doc: None,
|
||||||
|
location: 0..10,
|
||||||
|
name: "foo",
|
||||||
|
public: false,
|
||||||
|
return_annotation: None,
|
||||||
|
return_type: (),
|
||||||
|
end_position: 51,
|
||||||
|
on_test_failure: FailImmediately,
|
||||||
|
},
|
||||||
|
)
|
|
@ -0,0 +1,80 @@
|
||||||
|
---
|
||||||
|
source: crates/aiken-lang/src/parser/expr/block.rs
|
||||||
|
description: "Code:\n\ntest foo() {\n {\n let a = Void\n a\n }\n let _ = True\n True\n}\n"
|
||||||
|
---
|
||||||
|
Test(
|
||||||
|
Function {
|
||||||
|
arguments: [],
|
||||||
|
body: Sequence {
|
||||||
|
location: 38..65,
|
||||||
|
expressions: [
|
||||||
|
Sequence {
|
||||||
|
location: 21..39,
|
||||||
|
expressions: [
|
||||||
|
Assignment {
|
||||||
|
location: 21..33,
|
||||||
|
value: Var {
|
||||||
|
location: 29..33,
|
||||||
|
name: "Void",
|
||||||
|
},
|
||||||
|
patterns: [
|
||||||
|
AssignmentPattern {
|
||||||
|
pattern: Var {
|
||||||
|
location: 25..26,
|
||||||
|
name: "a",
|
||||||
|
},
|
||||||
|
annotation: None,
|
||||||
|
location: 25..26,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
kind: Let {
|
||||||
|
backpassing: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Var {
|
||||||
|
location: 38..39,
|
||||||
|
name: "a",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
Sequence {
|
||||||
|
location: 46..65,
|
||||||
|
expressions: [
|
||||||
|
Assignment {
|
||||||
|
location: 46..58,
|
||||||
|
value: Var {
|
||||||
|
location: 54..58,
|
||||||
|
name: "True",
|
||||||
|
},
|
||||||
|
patterns: [
|
||||||
|
AssignmentPattern {
|
||||||
|
pattern: Discard {
|
||||||
|
name: "_",
|
||||||
|
location: 50..51,
|
||||||
|
},
|
||||||
|
annotation: None,
|
||||||
|
location: 50..51,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
kind: Let {
|
||||||
|
backpassing: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Var {
|
||||||
|
location: 61..65,
|
||||||
|
name: "True",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
doc: None,
|
||||||
|
location: 0..10,
|
||||||
|
name: "foo",
|
||||||
|
public: false,
|
||||||
|
return_annotation: None,
|
||||||
|
return_type: (),
|
||||||
|
end_position: 66,
|
||||||
|
on_test_failure: FailImmediately,
|
||||||
|
},
|
||||||
|
)
|
Loading…
Reference in New Issue