wip
This commit is contained in:
@@ -1100,7 +1100,7 @@ impl<'a> Parser<'a> {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Expression::TupleAssignment(Spanned {
|
||||
span,
|
||||
node: TupleAssignmentExpression {
|
||||
@@ -1118,13 +1118,7 @@ impl<'a> Parser<'a> {
|
||||
})
|
||||
};
|
||||
|
||||
expressions.insert(
|
||||
i,
|
||||
Spanned {
|
||||
span,
|
||||
node,
|
||||
},
|
||||
);
|
||||
expressions.insert(i, Spanned { span, node });
|
||||
}
|
||||
}
|
||||
operators.retain(|symbol| !matches!(symbol, Symbol::Assign));
|
||||
@@ -1188,7 +1182,6 @@ impl<'a> Parser<'a> {
|
||||
// Next toekn is a comma, we need to consume it and advance 1 more time.
|
||||
self.assign_next()?;
|
||||
self.assign_next()?;
|
||||
println!("{:?}", self.current_token);
|
||||
items.push(self.expression()?.ok_or(Error::UnexpectedEOF)?);
|
||||
}
|
||||
|
||||
|
||||
@@ -253,3 +253,37 @@ fn test_tuple_assignment_with_function_call_with_underscore() -> Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tuple_declaration_with_complex_expressions() -> Result<()> {
|
||||
let expr = parser!("let (x, y) = (1 + 1, doSomething());")
|
||||
.parse()?
|
||||
.unwrap();
|
||||
|
||||
assert_eq!("(let (x, y) = ((1 + 1), doSomething()))", expr.to_string());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tuple_assignment_with_complex_expressions() -> Result<()> {
|
||||
let expr = parser!("(x, y) = (doSomething(), 123 / someValue.Setting);")
|
||||
.parse()?
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
"((x, y) = (doSomething(), (123 / someValue.Setting)))",
|
||||
expr.to_string()
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tuple_declaration_all_complex_expressions() -> Result<()> {
|
||||
let expr = parser!("let (x, y) = (a + b, c * d);").parse()?.unwrap();
|
||||
|
||||
assert_eq!("(let (x, y) = ((a + b), (c * d)))", expr.to_string());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user