mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Desugar stmt expr before checking whether it's suffixed
This commit is contained in:
parent
01c94050c8
commit
460fa693fd
3 changed files with 12 additions and 6 deletions
|
@ -207,7 +207,9 @@ fn desugar_value_def<'a>(
|
|||
// _ : {}
|
||||
// _ = stmt_expr!
|
||||
|
||||
if env.fx_mode == FxMode::Task && !is_expr_suffixed(&stmt_expr.value) {
|
||||
let desugared_expr = desugar_expr(env, scope, stmt_expr);
|
||||
|
||||
if env.fx_mode == FxMode::Task && !is_expr_suffixed(&desugared_expr.value) {
|
||||
env.problems.push(Problem::StmtAfterExpr(stmt_expr.region));
|
||||
|
||||
return ValueDef::StmtAfterExpr;
|
||||
|
@ -229,7 +231,7 @@ fn desugar_value_def<'a>(
|
|||
)),
|
||||
lines_between: &[],
|
||||
body_pattern: new_pat,
|
||||
body_expr: desugar_expr(env, scope, stmt_expr),
|
||||
body_expr: desugared_expr,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -592,10 +592,7 @@ pub fn is_top_level_suffixed(expr: &Expr) -> bool {
|
|||
pub fn is_expr_suffixed(expr: &Expr) -> bool {
|
||||
match expr {
|
||||
// expression without arguments, `read!`
|
||||
Expr::Var {
|
||||
module_name: _,
|
||||
ident,
|
||||
} => ident.ends_with('!'),
|
||||
Expr::Var { .. } => false,
|
||||
|
||||
Expr::TrySuffix { .. } => true,
|
||||
|
||||
|
|
|
@ -5,5 +5,12 @@ import pf.Effect
|
|||
main : {} => {}
|
||||
main = \{} ->
|
||||
line = Effect.getLine! {}
|
||||
|
||||
if line == "secret" then
|
||||
Effect.putLine! "You found the secret"
|
||||
Effect.putLine! "Congratulations!"
|
||||
else
|
||||
{}
|
||||
|
||||
Effect.putLine! "You entered: $(line)"
|
||||
Effect.putLine! "It is known"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue