desugar no args correctly e.g. Stdin.line!

This commit is contained in:
Luke Boswell 2024-03-21 19:25:34 +11:00
parent 5e2fc1c3fd
commit 4035221dac
No known key found for this signature in database
GPG Key ID: F6DB3C9DB47377B0
2 changed files with 9 additions and 0 deletions

View File

@ -339,6 +339,7 @@ fn unwrap_suffixed_def_and_pattern<'a>(
) {
match value_def {
ValueDef::Body(pattern, suffixed_expression) => match suffixed_expression.value {
// The Suffixed has arguments applied e.g. `Stdout.line! "Hello World"`
Apply(sub_loc, suffixed_args, called_via) => match sub_loc.value {
Suffixed(sub_expr) => (
Apply(
@ -350,6 +351,8 @@ fn unwrap_suffixed_def_and_pattern<'a>(
),
_ => unreachable!("should have a suffixed Apply inside Body def"),
},
// The Suffixed has NIL arguments applied e.g. `Stdin.line!`
Suffixed(sub_expr) => (*sub_expr, pattern),
_ => {
unreachable!("should have a suffixed Apply inside Body def")
}

View File

@ -601,11 +601,17 @@ impl<'a> Defs<'a> {
let index = value_index.index();
if let ValueDef::Body(_, expr) = &self.value_defs[index] {
// The Suffixed has arguments applied e.g. `Stdout.line! "Hello World"`
if let Expr::Apply(sub_expr, _, _) = expr.value {
if let Expr::Suffixed(_) = sub_expr.value {
return Some((tag_index, index));
}
}
// The Suffixed has NO arguments applied e.g. `Stdin.line!`
if let Expr::Suffixed(_) = expr.value {
return Some((tag_index, index));
}
}
}
}