mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Support passing values into dbg
with the pipe operator
In order to desugar `dbg` in a pipeline we need to allow a bare `dbg` node in desugaring and only report it as an error if the bare node survives to the next step of canonicalization. This means we move the error code out of `desugar_expr` and into `canonicalize_expr`. This is much simpler to do now that these functions use the same `env` struct, since previously we would have had to pass down extra args to `canonicalize_expr`. Sharing the `env` struct means that we also don't have to worry about calculating `line_info` more than once.
This commit is contained in:
parent
b515bfa77e
commit
19931ecd43
10 changed files with 200 additions and 28 deletions
|
@ -1209,8 +1209,20 @@ pub fn canonicalize_expr<'a>(
|
|||
output,
|
||||
)
|
||||
}
|
||||
ast::Expr::Dbg | ast::Expr::DbgStmt(_, _) => {
|
||||
internal_error!("Dbg should have been desugared by now")
|
||||
ast::Expr::Dbg => {
|
||||
// Dbg was not desugared as either part of an `Apply` or a `Pizza` binop, so it's
|
||||
// invalid.
|
||||
env.problem(Problem::UnappliedDbg { region });
|
||||
|
||||
let invalid_dbg_expr = crate::desugar::desugar_invalid_dbg_expr(env, scope, region);
|
||||
|
||||
let (loc_expr, output) =
|
||||
canonicalize_expr(env, var_store, scope, region, invalid_dbg_expr);
|
||||
|
||||
(loc_expr.value, output)
|
||||
}
|
||||
ast::Expr::DbgStmt(_, _) => {
|
||||
internal_error!("DbgStmt should have been desugared by now")
|
||||
}
|
||||
ast::Expr::LowLevelDbg((source_location, source), message, continuation) => {
|
||||
let mut output = Output::default();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue