mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Canonicalize crash
This commit is contained in:
parent
1011ce9fba
commit
dd05d813a9
5 changed files with 15 additions and 4 deletions
|
@ -376,6 +376,7 @@ fn deep_copy_expr_help<C: CopyEnv>(env: &mut C, copied: &mut Vec<Variable>, expr
|
|||
*called_via,
|
||||
)
|
||||
}
|
||||
Crash => Crash,
|
||||
RunLowLevel { op, args, ret_var } => RunLowLevel {
|
||||
op: *op,
|
||||
args: args
|
||||
|
|
|
@ -166,6 +166,9 @@ pub enum Expr {
|
|||
/// Empty record constant
|
||||
EmptyRecord,
|
||||
|
||||
/// The "crash" keyword
|
||||
Crash,
|
||||
|
||||
/// Look up exactly one field on a record, e.g. (expr).foo.
|
||||
Access {
|
||||
record_var: Variable,
|
||||
|
@ -309,6 +312,7 @@ impl Expr {
|
|||
}
|
||||
Self::Expect { .. } => Category::Expect,
|
||||
Self::ExpectFx { .. } => Category::Expect,
|
||||
Self::Crash => Category::Crash,
|
||||
|
||||
Self::Dbg { .. } => Category::Expect,
|
||||
|
||||
|
@ -874,6 +878,7 @@ pub fn canonicalize_expr<'a>(
|
|||
|
||||
(RuntimeError(problem), Output::default())
|
||||
}
|
||||
ast::Expr::Crash => (Crash, Output::default()),
|
||||
ast::Expr::Defs(loc_defs, loc_ret) => {
|
||||
// The body expression gets a new scope for canonicalization,
|
||||
scope.inner_scope(|inner_scope| {
|
||||
|
@ -1720,7 +1725,8 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
|
|||
| other @ RunLowLevel { .. }
|
||||
| other @ TypedHole { .. }
|
||||
| other @ ForeignCall { .. }
|
||||
| other @ OpaqueWrapFunction(_) => other,
|
||||
| other @ OpaqueWrapFunction(_)
|
||||
| other @ Crash => other,
|
||||
|
||||
List {
|
||||
elem_var,
|
||||
|
@ -2828,7 +2834,8 @@ fn get_lookup_symbols(expr: &Expr) -> Vec<ExpectLookup> {
|
|||
| Expr::EmptyRecord
|
||||
| Expr::TypedHole(_)
|
||||
| Expr::RuntimeError(_)
|
||||
| Expr::OpaqueWrapFunction(_) => {}
|
||||
| Expr::OpaqueWrapFunction(_)
|
||||
| Expr::Crash => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1056,7 +1056,8 @@ fn fix_values_captured_in_closure_expr(
|
|||
| TypedHole { .. }
|
||||
| RuntimeError(_)
|
||||
| ZeroArgumentTag { .. }
|
||||
| Accessor { .. } => {}
|
||||
| Accessor { .. }
|
||||
| Crash => {}
|
||||
|
||||
List { loc_elems, .. } => {
|
||||
for elem in loc_elems.iter_mut() {
|
||||
|
|
|
@ -138,7 +138,8 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Loc<Expr<'a>>) -> &'a Loc
|
|||
| MalformedClosure
|
||||
| PrecedenceConflict { .. }
|
||||
| Tag(_)
|
||||
| OpaqueRef(_) => loc_expr,
|
||||
| OpaqueRef(_)
|
||||
| Crash => loc_expr,
|
||||
|
||||
TupleAccess(_sub_expr, _paths) => todo!("Handle TupleAccess"),
|
||||
RecordAccess(sub_expr, paths) => {
|
||||
|
|
|
@ -185,6 +185,7 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expr: &Expr, var: Variable) {
|
|||
}
|
||||
Expr::Var(..) => { /* terminal */ }
|
||||
Expr::AbilityMember(..) => { /* terminal */ }
|
||||
Expr::Crash => { /* terminal */ }
|
||||
Expr::If {
|
||||
cond_var,
|
||||
branches,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue