mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Merge remote-tracking branch 'remote/main' into builtin-task
This commit is contained in:
commit
eca453d07f
367 changed files with 14084 additions and 12080 deletions
|
@ -10,7 +10,7 @@ use roc_module::ident::ModuleName;
|
|||
use roc_parse::ast::Expr::{self, *};
|
||||
use roc_parse::ast::{
|
||||
AssignedField, Collection, ModuleImportParams, OldRecordBuilderField, Pattern, StrLiteral,
|
||||
StrSegment, ValueDef, WhenBranch,
|
||||
StrSegment, TypeAnnotation, ValueDef, WhenBranch,
|
||||
};
|
||||
use roc_region::all::{LineInfo, Loc, Region};
|
||||
|
||||
|
@ -154,15 +154,26 @@ fn desugar_value_def<'a>(
|
|||
IngestedFileImport(_) => *def,
|
||||
|
||||
Stmt(stmt_expr) => {
|
||||
// desugar into a Body({}, stmt_expr)
|
||||
let loc_pattern = arena.alloc(Loc::at(
|
||||
stmt_expr.region,
|
||||
Pattern::RecordDestructure(Collection::empty()),
|
||||
));
|
||||
Body(
|
||||
loc_pattern,
|
||||
desugar_expr(arena, stmt_expr, src, line_info, module_path),
|
||||
)
|
||||
// desugar `stmt_expr!` to
|
||||
// _ : {}
|
||||
// _ = stmt_expr!
|
||||
|
||||
let region = stmt_expr.region;
|
||||
let new_pat = arena.alloc(Loc::at(region, Pattern::Underscore("#!stmt")));
|
||||
|
||||
ValueDef::AnnotatedBody {
|
||||
ann_pattern: new_pat,
|
||||
ann_type: arena.alloc(Loc::at(
|
||||
region,
|
||||
TypeAnnotation::Record {
|
||||
fields: Collection::empty(),
|
||||
ext: None,
|
||||
},
|
||||
)),
|
||||
comment: None,
|
||||
body_pattern: new_pat,
|
||||
body_expr: desugar_expr(arena, stmt_expr, src, line_info, module_path),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +222,7 @@ pub fn desugar_value_def_suffixed<'a>(arena: &'a Bump, value_def: ValueDef<'a>)
|
|||
arena,
|
||||
Body(
|
||||
loc_pattern,
|
||||
apply_task_await(arena, loc_expr.region, sub_arg, sub_pat, sub_new),
|
||||
apply_task_await(arena, loc_expr.region, sub_arg, sub_pat, sub_new, None),
|
||||
),
|
||||
),
|
||||
Err(..) => Body(
|
||||
|
@ -254,6 +265,7 @@ pub fn desugar_value_def_suffixed<'a>(arena: &'a Bump, value_def: ValueDef<'a>)
|
|||
sub_arg,
|
||||
sub_pat,
|
||||
sub_new,
|
||||
Some((ann_pattern, ann_type)),
|
||||
),
|
||||
},
|
||||
),
|
||||
|
@ -1349,10 +1361,6 @@ fn binop_to_function(binop: BinOp) -> (&'static str, &'static str) {
|
|||
And => (ModuleName::BOOL, "and"),
|
||||
Or => (ModuleName::BOOL, "or"),
|
||||
Pizza => unreachable!("Cannot desugar the |> operator"),
|
||||
Assignment => unreachable!("Cannot desugar the = operator"),
|
||||
IsAliasType => unreachable!("Cannot desugar the : operator"),
|
||||
IsOpaqueType => unreachable!("Cannot desugar the := operator"),
|
||||
Backpassing => unreachable!("Cannot desugar the <- operator"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use roc_error_macros::internal_error;
|
|||
use roc_module::called_via::CalledVia;
|
||||
use roc_module::ident::ModuleName;
|
||||
use roc_parse::ast::Expr::{self, *};
|
||||
use roc_parse::ast::{is_expr_suffixed, Pattern, ValueDef, WhenBranch};
|
||||
use roc_parse::ast::{is_expr_suffixed, Pattern, TypeAnnotation, ValueDef, WhenBranch};
|
||||
use roc_region::all::{Loc, Region};
|
||||
use std::cell::Cell;
|
||||
|
||||
|
@ -23,14 +23,23 @@ fn next_unique_suffixed_ident() -> String {
|
|||
|
||||
// # is used as prefix because it's impossible for code authors to define names like this.
|
||||
// This makes it easy to see this identifier was created by the compiler.
|
||||
format!("#!a{}", count)
|
||||
format!("#!{}", count)
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
///
|
||||
pub enum EUnwrapped<'a> {
|
||||
/// First suffixed expression in a definition. Emitted if an expression has def pattern
|
||||
/// e.g. x = first! (second! 42)
|
||||
/// The first unwrap will produce
|
||||
/// `UnwrappedDefExpr<first (second! 42)>`
|
||||
UnwrappedDefExpr(&'a Loc<Expr<'a>>),
|
||||
|
||||
/// Suffixed sub expression
|
||||
/// e.g. x = first! (second! 42)
|
||||
/// In this example, the second unwrap (after unwrapping the top level `first!`) will produce
|
||||
/// `UnwrappedSubExpr<{ sub_arg: second 42, sub_pat: #!0_arg, sub_new: #!0_arg }>`
|
||||
UnwrappedSubExpr {
|
||||
/// the unwrapped expression argument for Task.await
|
||||
sub_arg: &'a Loc<Expr<'a>>,
|
||||
|
@ -42,6 +51,7 @@ pub enum EUnwrapped<'a> {
|
|||
sub_new: &'a Loc<Expr<'a>>,
|
||||
},
|
||||
|
||||
/// Malformed use of the suffix
|
||||
Malformed,
|
||||
}
|
||||
|
||||
|
@ -59,20 +69,18 @@ fn init_unwrapped_err<'a>(
|
|||
None => {
|
||||
// Provide an intermediate answer expression and pattern when unwrapping a
|
||||
// (sub) expression.
|
||||
// e.g. `x = foo (bar!)` unwraps to `x = Task.await (bar) \#!a0 -> foo #!a0`
|
||||
let answer_ident = arena.alloc(next_unique_suffixed_ident());
|
||||
// e.g. `x = foo (bar!)` unwraps to `x = Task.await (bar) \#!0_arg -> foo #!0_arg`
|
||||
let ident = arena.alloc(format!("{}_arg", next_unique_suffixed_ident()));
|
||||
let sub_new = arena.alloc(Loc::at(
|
||||
unwrapped_expr.region,
|
||||
Expr::Var {
|
||||
module_name: "",
|
||||
ident: answer_ident,
|
||||
ident,
|
||||
},
|
||||
));
|
||||
let sub_pat = arena.alloc(Loc::at(
|
||||
unwrapped_expr.region,
|
||||
Pattern::Identifier {
|
||||
ident: answer_ident,
|
||||
},
|
||||
Pattern::Identifier { ident },
|
||||
));
|
||||
|
||||
Err(EUnwrapped::UnwrappedSubExpr {
|
||||
|
@ -240,7 +248,7 @@ pub fn unwrap_suffixed_expression_closure_help<'a>(
|
|||
Ok(new_closure)
|
||||
}
|
||||
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
|
||||
let new_closure_loc_ret = apply_task_await(arena, loc_expr.region, sub_arg, sub_pat, sub_new);
|
||||
let new_closure_loc_ret = apply_task_await(arena, loc_expr.region, sub_arg, sub_pat, sub_new, None);
|
||||
let new_closure = arena.alloc(Loc::at(loc_expr.region, Expr::Closure(closure_args, new_closure_loc_ret)));
|
||||
Ok(new_closure)
|
||||
}
|
||||
|
@ -361,8 +369,14 @@ pub fn unwrap_suffixed_expression_if_then_else_help<'a>(
|
|||
sub_pat,
|
||||
sub_new,
|
||||
}) => {
|
||||
let unwrapped_expression =
|
||||
apply_task_await(arena, sub_arg.region, sub_arg, sub_pat, sub_new);
|
||||
let unwrapped_expression = apply_task_await(
|
||||
arena,
|
||||
sub_arg.region,
|
||||
sub_arg,
|
||||
sub_pat,
|
||||
sub_new,
|
||||
None,
|
||||
);
|
||||
|
||||
let mut new_if_thens = Vec::new_in(arena);
|
||||
|
||||
|
@ -437,6 +451,7 @@ pub fn unwrap_suffixed_expression_if_then_else_help<'a>(
|
|||
sub_arg,
|
||||
sub_pat,
|
||||
new_if,
|
||||
None,
|
||||
);
|
||||
|
||||
return unwrap_suffixed_expression(
|
||||
|
@ -464,6 +479,7 @@ pub fn unwrap_suffixed_expression_if_then_else_help<'a>(
|
|||
sub_arg,
|
||||
sub_pat,
|
||||
after_if,
|
||||
None,
|
||||
);
|
||||
|
||||
let before_if_then = arena.alloc(Loc::at(
|
||||
|
@ -500,7 +516,7 @@ pub fn unwrap_suffixed_expression_if_then_else_help<'a>(
|
|||
sub_new,
|
||||
}) => {
|
||||
let unwrapped_final_else =
|
||||
apply_task_await(arena, sub_arg.region, sub_arg, sub_pat, sub_new);
|
||||
apply_task_await(arena, sub_arg.region, sub_arg, sub_pat, sub_new, None);
|
||||
|
||||
let new_if = arena.alloc(Loc::at(
|
||||
loc_expr.region,
|
||||
|
@ -535,7 +551,7 @@ pub fn unwrap_suffixed_expression_when_help<'a>(
|
|||
if is_expr_suffixed(&branch_loc_expr.value) {
|
||||
let unwrapped_branch_value = match unwrap_suffixed_expression(arena, branch_loc_expr, None) {
|
||||
Ok(unwrapped_branch_value) => unwrapped_branch_value,
|
||||
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => apply_task_await(arena, branch_loc_expr.region, sub_arg, sub_pat, sub_new),
|
||||
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => apply_task_await(arena, branch_loc_expr.region, sub_arg, sub_pat, sub_new, None),
|
||||
Err(..) => return Err(EUnwrapped::Malformed),
|
||||
};
|
||||
|
||||
|
@ -564,7 +580,7 @@ pub fn unwrap_suffixed_expression_when_help<'a>(
|
|||
}
|
||||
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
|
||||
let new_when = arena.alloc(Loc::at(loc_expr.region, Expr::When(sub_new, branches)));
|
||||
let applied_task_await = apply_task_await(arena,loc_expr.region,sub_arg,sub_pat,new_when);
|
||||
let applied_task_await = apply_task_await(arena,loc_expr.region,sub_arg,sub_pat,new_when, None);
|
||||
Ok(applied_task_await)
|
||||
}
|
||||
Err(EUnwrapped::UnwrappedDefExpr(..))
|
||||
|
@ -601,15 +617,15 @@ pub fn unwrap_suffixed_expression_defs_help<'a>(
|
|||
|
||||
let maybe_suffixed_value_def = match current_value_def {
|
||||
Annotation(..) | Dbg{..} | Expect{..} | ExpectFx{..} | Stmt(..) | ModuleImport{..} | IngestedFileImport(_) => None,
|
||||
AnnotatedBody { body_pattern, body_expr, .. } => Some((body_pattern, body_expr)),
|
||||
Body (def_pattern, def_expr, .. ) => Some((def_pattern, def_expr)),
|
||||
AnnotatedBody { body_pattern, body_expr, ann_type, ann_pattern, .. } => Some((body_pattern, body_expr, Some((ann_pattern, ann_type)))),
|
||||
Body (def_pattern, def_expr) => Some((def_pattern, def_expr, None)),
|
||||
};
|
||||
|
||||
match maybe_suffixed_value_def {
|
||||
None => {
|
||||
// We can't unwrap this def type, continue
|
||||
},
|
||||
Some((def_pattern, def_expr)) => {
|
||||
Some((def_pattern, def_expr, ann_type)) => {
|
||||
match unwrap_suffixed_expression(arena, def_expr, Some(def_pattern)) {
|
||||
Ok(unwrapped_def) => {
|
||||
current_value_def.replace_expr(unwrapped_def);
|
||||
|
@ -626,14 +642,14 @@ pub fn unwrap_suffixed_expression_defs_help<'a>(
|
|||
Ok(next_expr) => next_expr,
|
||||
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
|
||||
// We need to apply Task.ok here as the defs final expression was unwrapped
|
||||
apply_task_await(arena,def_expr.region,sub_arg,sub_pat,sub_new)
|
||||
apply_task_await(arena,def_expr.region,sub_arg,sub_pat,sub_new, None)
|
||||
}
|
||||
Err(EUnwrapped::UnwrappedDefExpr(..)) | Err(EUnwrapped::Malformed) => {
|
||||
// TODO handle case when we have maybe_def_pat so can return an unwrapped up
|
||||
return Err(EUnwrapped::Malformed);
|
||||
},
|
||||
};
|
||||
return unwrap_suffixed_expression(arena, apply_task_await(arena,def_expr.region,unwrapped_expr,def_pattern,next_expr), maybe_def_pat);
|
||||
return unwrap_suffixed_expression(arena, apply_task_await(arena,def_expr.region,unwrapped_expr,def_pattern,next_expr, ann_type), maybe_def_pat);
|
||||
} else if before_empty {
|
||||
// NIL before, SOME after -> FIRST DEF
|
||||
let new_defs = arena.alloc(Loc::at(def_expr.region, Defs(arena.alloc(split_defs.after), loc_ret)));
|
||||
|
@ -641,7 +657,7 @@ pub fn unwrap_suffixed_expression_defs_help<'a>(
|
|||
let next_expr = match unwrap_suffixed_expression(arena,new_defs,maybe_def_pat){
|
||||
Ok(next_expr) => next_expr,
|
||||
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
|
||||
apply_task_await(arena, def_expr.region, sub_arg, sub_pat, sub_new)
|
||||
apply_task_await(arena, def_expr.region, sub_arg, sub_pat, sub_new, None)
|
||||
}
|
||||
Err(EUnwrapped::UnwrappedDefExpr(..)) | Err(EUnwrapped::Malformed) => {
|
||||
// TODO handle case when we have maybe_def_pat so can return an unwrapped up
|
||||
|
@ -649,19 +665,19 @@ pub fn unwrap_suffixed_expression_defs_help<'a>(
|
|||
},
|
||||
};
|
||||
|
||||
return unwrap_suffixed_expression(arena, apply_task_await(arena,def_expr.region,unwrapped_expr,def_pattern,next_expr), maybe_def_pat);
|
||||
return unwrap_suffixed_expression(arena, apply_task_await(arena,def_expr.region,unwrapped_expr,def_pattern,next_expr,ann_type), maybe_def_pat);
|
||||
} else if after_empty {
|
||||
// SOME before, NIL after -> LAST DEF
|
||||
// We pass None as a def pattern here because it's desugaring of the ret expression
|
||||
match unwrap_suffixed_expression(arena,loc_ret,None){
|
||||
Ok(new_loc_ret) => {
|
||||
let applied_task_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret);
|
||||
let applied_task_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret, ann_type);
|
||||
let new_defs = arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(split_defs.before), applied_task_await)));
|
||||
return unwrap_suffixed_expression(arena, new_defs, maybe_def_pat);
|
||||
},
|
||||
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
|
||||
let new_loc_ret = apply_task_await(arena,def_expr.region,sub_arg,sub_pat,sub_new);
|
||||
let applied_task_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret);
|
||||
let new_loc_ret = apply_task_await(arena,def_expr.region,sub_arg,sub_pat,sub_new, None);
|
||||
let applied_task_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret, ann_type);
|
||||
let new_defs = arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(split_defs.before), applied_task_await)));
|
||||
return unwrap_suffixed_expression(arena, new_defs, maybe_def_pat);
|
||||
}
|
||||
|
@ -679,13 +695,13 @@ pub fn unwrap_suffixed_expression_defs_help<'a>(
|
|||
|
||||
match unwrap_suffixed_expression(arena,after_defs,maybe_def_pat){
|
||||
Ok(new_loc_ret) => {
|
||||
let applied_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret);
|
||||
let applied_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret, ann_type);
|
||||
let new_defs = arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(split_defs.before), applied_await)));
|
||||
return unwrap_suffixed_expression(arena, new_defs, maybe_def_pat);
|
||||
},
|
||||
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
|
||||
let new_loc_ret = apply_task_await(arena, def_expr.region, sub_arg, sub_pat, sub_new);
|
||||
let applied_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret);
|
||||
let new_loc_ret = apply_task_await(arena, def_expr.region, sub_arg, sub_pat, sub_new, None);
|
||||
let applied_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret, ann_type);
|
||||
let new_defs = arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(split_defs.before), applied_await)));
|
||||
return unwrap_suffixed_expression(arena, new_defs, maybe_def_pat);
|
||||
}
|
||||
|
@ -700,7 +716,7 @@ pub fn unwrap_suffixed_expression_defs_help<'a>(
|
|||
let new_body_def = ValueDef::Body(def_pattern, sub_new);
|
||||
local_defs.replace_with_value_def(tag_index,new_body_def, sub_new.region);
|
||||
let new_defs_expr = arena.alloc(Loc::at(def_expr.region,Defs(arena.alloc(local_defs), loc_ret)));
|
||||
let replaced_def = apply_task_await(arena,def_expr.region,sub_arg,sub_pat,new_defs_expr);
|
||||
let replaced_def = apply_task_await(arena,def_expr.region,sub_arg,sub_pat,new_defs_expr, ann_type);
|
||||
return unwrap_suffixed_expression(arena,replaced_def,maybe_def_pat);
|
||||
}
|
||||
Err(err) => return Err(err)
|
||||
|
@ -710,14 +726,14 @@ pub fn unwrap_suffixed_expression_defs_help<'a>(
|
|||
}
|
||||
|
||||
// try to unwrap the loc_ret
|
||||
match unwrap_suffixed_expression(arena,loc_ret,maybe_def_pat){
|
||||
match unwrap_suffixed_expression(arena,loc_ret,None){
|
||||
Ok(new_loc_ret) => {
|
||||
Ok(arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(local_defs), new_loc_ret))))
|
||||
Ok(arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(local_defs), new_loc_ret))))
|
||||
},
|
||||
Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => {
|
||||
let new_loc_ret = apply_task_await(arena, loc_expr.region,sub_arg,sub_pat,sub_new);
|
||||
let new_loc_ret = apply_task_await(arena, loc_expr.region,sub_arg,sub_pat,sub_new, None);
|
||||
let new_defs = arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(local_defs), new_loc_ret)));
|
||||
unwrap_suffixed_expression(arena, new_defs, maybe_def_pat)
|
||||
unwrap_suffixed_expression(arena, new_defs, None)
|
||||
}
|
||||
Err(EUnwrapped::UnwrappedDefExpr(..)) => {
|
||||
// TODO confirm this is correct with test case
|
||||
|
@ -761,7 +777,14 @@ fn unwrap_low_level_dbg<'a>(
|
|||
|
||||
unwrap_suffixed_expression(
|
||||
arena,
|
||||
apply_task_await(arena, new_dbg.region, sub_arg, sub_pat, new_dbg),
|
||||
apply_task_await(
|
||||
arena,
|
||||
new_dbg.region,
|
||||
sub_arg,
|
||||
sub_pat,
|
||||
new_dbg,
|
||||
None,
|
||||
),
|
||||
maybe_def_pat,
|
||||
)
|
||||
}
|
||||
|
@ -813,33 +836,122 @@ fn unwrap_low_level_dbg<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
/// Helper for `Task.await (loc_arg) \loc_pat -> loc_new`
|
||||
/// Helper for `Task.await loc_expr \loc_pat -> loc_cont`
|
||||
pub fn apply_task_await<'a>(
|
||||
arena: &'a Bump,
|
||||
region: Region,
|
||||
loc_arg: &'a Loc<Expr<'a>>,
|
||||
loc_expr: &'a Loc<Expr<'a>>,
|
||||
loc_pat: &'a Loc<Pattern<'a>>,
|
||||
loc_new: &'a Loc<Expr<'a>>,
|
||||
loc_cont: &'a Loc<Expr<'a>>,
|
||||
maybe_loc_ann: Option<(&'a Loc<Pattern>, &'a Loc<TypeAnnotation<'a>>)>,
|
||||
) -> &'a Loc<Expr<'a>> {
|
||||
// If the pattern and the new are matching answers then we don't need to unwrap anything
|
||||
// e.g. `Task.await foo \#!a1 -> Task.ok #!a1` is the same as `foo`
|
||||
if is_matching_intermediate_answer(loc_pat, loc_new) {
|
||||
return loc_arg;
|
||||
let task_await_first_arg = match maybe_loc_ann {
|
||||
Some((loc_ann_pat, loc_type)) => {
|
||||
// loc_ann_pat : loc_type
|
||||
// loc_pat = loc_expr!
|
||||
// loc_cont
|
||||
|
||||
// desugar to
|
||||
// Task.await
|
||||
// (
|
||||
// #!0_expr : Task loc_type _
|
||||
// #!0_expr = loc_expr
|
||||
// #!0_expr
|
||||
// )
|
||||
// \loc_pat -> loc_cont
|
||||
use roc_parse::ast::*;
|
||||
|
||||
// #!0_expr or #!0_stmt
|
||||
let new_ident = next_unique_suffixed_ident();
|
||||
let new_ident = match loc_pat.value {
|
||||
Pattern::Underscore("#!stmt") => format!("{}_stmt", new_ident),
|
||||
Pattern::Identifier { ident }
|
||||
if ident.starts_with('#') && ident.ends_with("_stmt") =>
|
||||
{
|
||||
format!("{}_stmt", new_ident)
|
||||
}
|
||||
_ => format!("{}_expr", new_ident),
|
||||
};
|
||||
let new_ident = arena.alloc(new_ident);
|
||||
|
||||
// #!0_expr (pattern)
|
||||
// #!0_expr : Task loc_type _
|
||||
// #!0_expr = loc_expr
|
||||
let value_def = ValueDef::AnnotatedBody {
|
||||
ann_pattern: arena.alloc(Loc::at(
|
||||
loc_ann_pat.region,
|
||||
Pattern::Identifier {
|
||||
ident: if loc_ann_pat.value.equivalent(&loc_pat.value) {
|
||||
new_ident
|
||||
} else {
|
||||
// create another pattern to preserve inconsistency
|
||||
arena.alloc(next_unique_suffixed_ident())
|
||||
},
|
||||
},
|
||||
)),
|
||||
ann_type: arena.alloc(Loc::at(
|
||||
loc_type.region,
|
||||
TypeAnnotation::Apply(
|
||||
arena.alloc(""),
|
||||
arena.alloc("Task"),
|
||||
arena.alloc([
|
||||
*loc_type,
|
||||
Loc::at(loc_type.region, TypeAnnotation::Inferred),
|
||||
]),
|
||||
),
|
||||
)),
|
||||
comment: None,
|
||||
body_pattern: arena.alloc(Loc::at(
|
||||
loc_pat.region,
|
||||
Pattern::Identifier { ident: new_ident },
|
||||
)),
|
||||
body_expr: loc_expr,
|
||||
};
|
||||
|
||||
// #!0_expr (variable)
|
||||
let new_var = arena.alloc(Loc::at(
|
||||
region,
|
||||
Expr::Var {
|
||||
module_name: "",
|
||||
ident: new_ident,
|
||||
},
|
||||
));
|
||||
|
||||
// (
|
||||
// #!0_expr : Task loc_type _
|
||||
// #!0_expr = loc_expr
|
||||
// #!0_expr
|
||||
// )
|
||||
let mut defs = roc_parse::ast::Defs::default();
|
||||
defs.push_value_def(value_def, region, &[], &[]);
|
||||
|
||||
arena.alloc(Loc::at(
|
||||
Region::span_across(&loc_ann_pat.region, &loc_expr.region),
|
||||
Defs(arena.alloc(defs), new_var),
|
||||
))
|
||||
}
|
||||
None => {
|
||||
// loc_pat = loc_expr!
|
||||
// loc_cont
|
||||
|
||||
// desugar to
|
||||
// Task.await loc_expr \loc_pat -> loc_cont
|
||||
loc_expr
|
||||
}
|
||||
};
|
||||
|
||||
// If the last expression is suffixed - don't await
|
||||
// e.g.
|
||||
// \x -> x!
|
||||
// \x -> x
|
||||
if is_matching_intermediate_answer(loc_pat, loc_cont) {
|
||||
return task_await_first_arg;
|
||||
}
|
||||
|
||||
let mut task_await_apply_args: Vec<&'a Loc<Expr<'a>>> = Vec::new_in(arena);
|
||||
|
||||
// apply the unwrapped suffixed expression
|
||||
task_await_apply_args.push(loc_arg);
|
||||
|
||||
// apply the closure
|
||||
let mut closure_pattern = Vec::new_in(arena);
|
||||
closure_pattern.push(*loc_pat);
|
||||
task_await_apply_args.push(arena.alloc(Loc::at(
|
||||
region,
|
||||
Closure(arena.alloc_slice_copy(closure_pattern.as_slice()), loc_new),
|
||||
)));
|
||||
// \loc_pat -> loc_cont
|
||||
let closure = arena.alloc(Loc::at(region, Closure(arena.alloc([*loc_pat]), loc_cont)));
|
||||
|
||||
// Task.await task_first_arg closure
|
||||
arena.alloc(Loc::at(
|
||||
region,
|
||||
Apply(
|
||||
|
@ -850,24 +962,12 @@ pub fn apply_task_await<'a>(
|
|||
ident: "await",
|
||||
},
|
||||
}),
|
||||
arena.alloc(task_await_apply_args),
|
||||
arena.alloc([task_await_first_arg, closure]),
|
||||
CalledVia::BangSuffix,
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
fn extract_wrapped_task_ok_value<'a>(loc_expr: &'a Loc<Expr<'a>>) -> Option<&'a Loc<Expr<'a>>> {
|
||||
match loc_expr.value {
|
||||
Expr::Apply(function, arguments, _) => match function.value {
|
||||
Var {
|
||||
module_name, ident, ..
|
||||
} if module_name == ModuleName::TASK && ident == "ok" => arguments.first().copied(),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_matching_intermediate_answer<'a>(
|
||||
loc_pat: &'a Loc<Pattern<'a>>,
|
||||
loc_new: &'a Loc<Expr<'a>>,
|
||||
|
@ -876,24 +976,18 @@ pub fn is_matching_intermediate_answer<'a>(
|
|||
Pattern::Identifier { ident, .. } => Some(ident),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let exp_ident = match loc_new.value {
|
||||
Expr::Var {
|
||||
module_name, ident, ..
|
||||
} if module_name.is_empty() && ident.starts_with('#') => Some(ident),
|
||||
module_name: "",
|
||||
ident,
|
||||
..
|
||||
} => Some(ident),
|
||||
_ => None,
|
||||
};
|
||||
let exp_ident_in_task = match extract_wrapped_task_ok_value(loc_new) {
|
||||
Some(task_expr) => match task_expr.value {
|
||||
Expr::Var {
|
||||
module_name, ident, ..
|
||||
} if module_name.is_empty() && ident.starts_with('#') => Some(ident),
|
||||
_ => None,
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
match (pat_ident, exp_ident, exp_ident_in_task) {
|
||||
(Some(a), Some(b), None) => a == b,
|
||||
(Some(a), None, Some(b)) => a == b,
|
||||
|
||||
match (pat_ident, exp_ident) {
|
||||
(Some(a), Some(b)) => a == b,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -35,7 +37,7 @@ Defs {
|
|||
@15-22 Closure(
|
||||
[
|
||||
@17-18 Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@15-22 Apply(
|
||||
|
@ -51,7 +53,7 @@ Defs {
|
|||
@15-22 Closure(
|
||||
[
|
||||
@20-21 Identifier {
|
||||
ident: "#!a1",
|
||||
ident: "#!1_arg",
|
||||
},
|
||||
],
|
||||
@15-22 Defs(
|
||||
|
@ -83,11 +85,11 @@ Defs {
|
|||
[
|
||||
@17-18 Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
@20-21 Var {
|
||||
module_name: "",
|
||||
ident: "#!a1",
|
||||
ident: "#!1_arg",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -35,7 +37,7 @@ Defs {
|
|||
@15-19 Closure(
|
||||
[
|
||||
@17-18 Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@15-19 Defs(
|
||||
|
@ -67,7 +69,7 @@ Defs {
|
|||
[
|
||||
@17-18 Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -45,7 +47,7 @@ Defs {
|
|||
@15-33 Closure(
|
||||
[
|
||||
Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@15-33 Defs(
|
||||
|
@ -78,7 +80,7 @@ Defs {
|
|||
@20-32 ParensAround(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -45,7 +47,7 @@ Defs {
|
|||
@15-35 Closure(
|
||||
[
|
||||
Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@15-35 Defs(
|
||||
|
@ -73,7 +75,7 @@ Defs {
|
|||
@16-26 ParensAround(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
),
|
||||
[
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -35,7 +37,7 @@ Defs {
|
|||
@15-22 Closure(
|
||||
[
|
||||
@15-16 Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@15-22 Defs(
|
||||
|
@ -67,7 +69,7 @@ Defs {
|
|||
[
|
||||
@15-16 Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
BinOp(
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -28,14 +30,58 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@11-15 Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
@11-15 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@11-15,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @11-15 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
ann_type: @11-15 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@11-15 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@11-15 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @11-15 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
body_expr: @11-15 Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
@11-15 Var {
|
||||
module_name: "",
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
),
|
||||
@11-15 Closure(
|
||||
[
|
||||
@11-15 RecordDestructure(
|
||||
[],
|
||||
@11-15 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@21-26 Apply(
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -35,7 +37,7 @@ Defs {
|
|||
@16-35 Closure(
|
||||
[
|
||||
Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@16-35 Defs(
|
||||
|
@ -63,7 +65,7 @@ Defs {
|
|||
@17-29 ParensAround(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
),
|
||||
[
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -55,25 +57,69 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@31-42 Apply(
|
||||
@31-42 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@31-42,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @31-43 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
ann_type: @31-43 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@31-43 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@31-43 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @31-43 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
body_expr: @31-42 Apply(
|
||||
@31-42 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@31-34 Var {
|
||||
module_name: "",
|
||||
ident: "msg",
|
||||
},
|
||||
],
|
||||
BinOp(
|
||||
Pizza,
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
@31-42 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
[
|
||||
@31-34 Var {
|
||||
module_name: "",
|
||||
ident: "msg",
|
||||
},
|
||||
],
|
||||
BinOp(
|
||||
Pizza,
|
||||
),
|
||||
),
|
||||
@31-42 Closure(
|
||||
[
|
||||
@31-42 RecordDestructure(
|
||||
[],
|
||||
@31-43 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@52-57 Apply(
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -70,38 +72,69 @@ Defs {
|
|||
ident: "msg",
|
||||
},
|
||||
],
|
||||
@78-91 Apply(
|
||||
@78-91 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
@56-91 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@82-91,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @56-57 Identifier {
|
||||
ident: "#!0_expr",
|
||||
},
|
||||
ann_type: @60-69 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@60-69 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@65-67 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@68-69 Inferred,
|
||||
],
|
||||
),
|
||||
@60-69 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @78-79 Identifier {
|
||||
ident: "#!0_expr",
|
||||
},
|
||||
body_expr: @82-91 Apply(
|
||||
@82-91 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@88-91 Var {
|
||||
module_name: "",
|
||||
ident: "msg",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
@82-91 Var {
|
||||
module_name: "",
|
||||
ident: "#!0_expr",
|
||||
},
|
||||
[
|
||||
@78-91 Apply(
|
||||
@78-91 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@88-91 Var {
|
||||
module_name: "",
|
||||
ident: "msg",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
@78-91 Closure(
|
||||
[
|
||||
@78-79 Identifier {
|
||||
ident: "y",
|
||||
},
|
||||
],
|
||||
@100-101 Var {
|
||||
module_name: "",
|
||||
ident: "y",
|
||||
},
|
||||
),
|
||||
],
|
||||
BangSuffix,
|
||||
),
|
||||
),
|
||||
},
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -98,23 +100,67 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@76-83 Apply(
|
||||
@76-83 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@76-83,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @76-83 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
ann_type: @76-83 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@76-83 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@76-83 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @76-83 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
body_expr: @76-83 Apply(
|
||||
@76-83 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@82-83 Var {
|
||||
module_name: "",
|
||||
ident: "a",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
@76-83 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
[
|
||||
@82-83 Var {
|
||||
module_name: "",
|
||||
ident: "a",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
@76-83 Closure(
|
||||
[
|
||||
@76-83 RecordDestructure(
|
||||
[],
|
||||
@76-83 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@92-99 Apply(
|
||||
|
@ -123,23 +169,67 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@92-99 Apply(
|
||||
@92-99 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@92-99,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @92-99 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
ann_type: @92-99 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@92-99 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@92-99 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @92-99 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
body_expr: @92-99 Apply(
|
||||
@92-99 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@98-99 Var {
|
||||
module_name: "",
|
||||
ident: "b",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
@92-99 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
[
|
||||
@98-99 Var {
|
||||
module_name: "",
|
||||
ident: "b",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
@92-99 Closure(
|
||||
[
|
||||
@92-99 RecordDestructure(
|
||||
[],
|
||||
@92-99 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@109-119 Apply(
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -38,7 +40,7 @@ Defs {
|
|||
ident: "foo",
|
||||
},
|
||||
],
|
||||
@29-49 LowLevelDbg(
|
||||
@29-36 LowLevelDbg(
|
||||
(
|
||||
"test.roc:3",
|
||||
" ",
|
||||
|
|
|
@ -13,17 +13,19 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@11-24 Apply(
|
||||
@11-24 Var {
|
||||
@11-17 Apply(
|
||||
@11-17 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
|
@ -32,13 +34,13 @@ Defs {
|
|||
module_name: "",
|
||||
ident: "a",
|
||||
},
|
||||
@11-24 Closure(
|
||||
@11-17 Closure(
|
||||
[
|
||||
@15-17 Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@11-24 LowLevelDbg(
|
||||
@11-17 LowLevelDbg(
|
||||
(
|
||||
"test.roc:2",
|
||||
"in",
|
||||
|
@ -51,7 +53,7 @@ Defs {
|
|||
[
|
||||
@15-17 Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
|
|
@ -17,11 +17,12 @@ Defs {
|
|||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 2, length = 0),
|
||||
Slice(start = 2, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
Newline,
|
||||
Newline,
|
||||
],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
|
@ -64,23 +65,67 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@25-39 Apply(
|
||||
@25-39 Var {
|
||||
module_name: "Stdout",
|
||||
ident: "line",
|
||||
@25-39 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@25-39,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @25-39 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
ann_type: @25-39 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@25-39 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@25-39 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @25-39 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
body_expr: @25-39 Apply(
|
||||
@25-39 Var {
|
||||
module_name: "Stdout",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@38-39 Var {
|
||||
module_name: "",
|
||||
ident: "a",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
@11-54 Var {
|
||||
module_name: "",
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
[
|
||||
@38-39 Var {
|
||||
module_name: "",
|
||||
ident: "a",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
@11-54 Closure(
|
||||
[
|
||||
@25-39 RecordDestructure(
|
||||
[],
|
||||
@25-39 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@45-54 Var {
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
|
|
@ -13,33 +13,56 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@11-31 Expect(
|
||||
@18-24 Apply(
|
||||
@20-22 Var {
|
||||
module_name: "Bool",
|
||||
ident: "isEq",
|
||||
},
|
||||
[
|
||||
@18-19 Num(
|
||||
"1",
|
||||
),
|
||||
@23-24 Num(
|
||||
"2",
|
||||
),
|
||||
@11-31 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
BinOp(
|
||||
Equals,
|
||||
),
|
||||
),
|
||||
regions: [
|
||||
@11-24,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Expect {
|
||||
condition: @18-24 Apply(
|
||||
@20-22 Var {
|
||||
module_name: "Bool",
|
||||
ident: "isEq",
|
||||
},
|
||||
[
|
||||
@18-19 Num(
|
||||
"1",
|
||||
),
|
||||
@23-24 Num(
|
||||
"2",
|
||||
),
|
||||
],
|
||||
BinOp(
|
||||
Equals,
|
||||
),
|
||||
),
|
||||
preceding_comment: @11-11,
|
||||
},
|
||||
],
|
||||
},
|
||||
@29-31 Var {
|
||||
module_name: "",
|
||||
ident: "x",
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -129,7 +131,7 @@ Defs {
|
|||
Closure(
|
||||
[
|
||||
Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!1_arg",
|
||||
},
|
||||
],
|
||||
@109-298 If(
|
||||
|
@ -144,7 +146,7 @@ Defs {
|
|||
@114-121 ParensAround(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!1_arg",
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -158,24 +160,68 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@140-152 Apply(
|
||||
@140-152 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@140-152,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @140-152 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
ann_type: @140-152 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@140-152 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@140-152 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @140-152 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
body_expr: @140-152 Apply(
|
||||
@140-152 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@146-152 Str(
|
||||
PlainLine(
|
||||
"fail",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
@140-152 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
[
|
||||
@146-152 Str(
|
||||
PlainLine(
|
||||
"fail",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
@140-152 Closure(
|
||||
[
|
||||
@140-152 RecordDestructure(
|
||||
[],
|
||||
@140-152 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@165-170 Apply(
|
||||
|
@ -218,7 +264,7 @@ Defs {
|
|||
Closure(
|
||||
[
|
||||
Identifier {
|
||||
ident: "#!a1",
|
||||
ident: "#!3_arg",
|
||||
},
|
||||
],
|
||||
@109-298 If(
|
||||
|
@ -227,7 +273,7 @@ Defs {
|
|||
@187-209 ParensAround(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "#!a1",
|
||||
ident: "#!3_arg",
|
||||
},
|
||||
),
|
||||
@227-239 Apply(
|
||||
|
@ -236,24 +282,68 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@227-239 Apply(
|
||||
@227-239 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@227-239,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @227-239 Identifier {
|
||||
ident: "#!2_stmt",
|
||||
},
|
||||
ann_type: @227-239 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@227-239 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@227-239 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @227-239 Identifier {
|
||||
ident: "#!2_stmt",
|
||||
},
|
||||
body_expr: @227-239 Apply(
|
||||
@227-239 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@233-239 Str(
|
||||
PlainLine(
|
||||
"nope",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
@227-239 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
ident: "#!2_stmt",
|
||||
},
|
||||
[
|
||||
@233-239 Str(
|
||||
PlainLine(
|
||||
"nope",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
@227-239 Closure(
|
||||
[
|
||||
@227-239 RecordDestructure(
|
||||
[],
|
||||
@227-239 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@252-257 Apply(
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -96,7 +98,7 @@ Defs {
|
|||
@79-87 Closure(
|
||||
[
|
||||
@79-87 Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@76-189 If(
|
||||
|
@ -104,7 +106,7 @@ Defs {
|
|||
(
|
||||
@79-87 Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
@101-112 Apply(
|
||||
@101-105 Var {
|
||||
|
@ -135,7 +137,7 @@ Defs {
|
|||
@125-132 Closure(
|
||||
[
|
||||
@125-132 Identifier {
|
||||
ident: "#!a1",
|
||||
ident: "#!1_arg",
|
||||
},
|
||||
],
|
||||
@76-189 If(
|
||||
|
@ -143,7 +145,7 @@ Defs {
|
|||
(
|
||||
@125-132 Var {
|
||||
module_name: "",
|
||||
ident: "#!a1",
|
||||
ident: "#!1_arg",
|
||||
},
|
||||
@146-160 Apply(
|
||||
@146-150 Var {
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -62,7 +64,7 @@ Defs {
|
|||
@11-26 Closure(
|
||||
[
|
||||
@24-25 Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@22-26 Apply(
|
||||
|
@ -73,7 +75,7 @@ Defs {
|
|||
[
|
||||
@24-25 Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -28,14 +30,58 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@11-15 Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
@11-15 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@11-15,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @11-15 Identifier {
|
||||
ident: "#!2_stmt",
|
||||
},
|
||||
ann_type: @11-15 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@11-15 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@11-15 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @11-15 Identifier {
|
||||
ident: "#!2_stmt",
|
||||
},
|
||||
body_expr: @11-15 Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
@11-15 Var {
|
||||
module_name: "",
|
||||
ident: "#!2_stmt",
|
||||
},
|
||||
),
|
||||
@11-15 Closure(
|
||||
[
|
||||
@11-15 RecordDestructure(
|
||||
[],
|
||||
@11-15 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@20-24 Apply(
|
||||
|
@ -44,14 +90,58 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@20-24 Var {
|
||||
module_name: "",
|
||||
ident: "bar",
|
||||
},
|
||||
@20-24 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@20-24,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @20-24 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
ann_type: @20-24 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@20-24 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@20-24 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @20-24 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
body_expr: @20-24 Var {
|
||||
module_name: "",
|
||||
ident: "bar",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
@20-24 Var {
|
||||
module_name: "",
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
),
|
||||
@20-24 Closure(
|
||||
[
|
||||
@20-24 RecordDestructure(
|
||||
[],
|
||||
@20-24 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@29-33 Var {
|
||||
|
|
|
@ -13,17 +13,19 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@0-26 Apply(
|
||||
@0-26 Var {
|
||||
@7-26 Apply(
|
||||
@7-26 Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -28,24 +30,68 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@11-23 Apply(
|
||||
@11-23 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@11-23,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @11-23 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
ann_type: @11-23 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@11-23 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@11-23 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @11-23 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
body_expr: @11-23 Apply(
|
||||
@11-23 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@17-23 Str(
|
||||
PlainLine(
|
||||
"Ahoy",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
@11-23 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
[
|
||||
@17-23 Str(
|
||||
PlainLine(
|
||||
"Ahoy",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
@11-23 Closure(
|
||||
[
|
||||
@11-23 RecordDestructure(
|
||||
[],
|
||||
@11-23 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@33-55 Apply(
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -57,8 +59,8 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@29-41 Apply(
|
||||
@29-41 Var {
|
||||
@33-41 Apply(
|
||||
@33-41 Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
|
|
|
@ -13,55 +13,88 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@11-24 Apply(
|
||||
@11-24 Var {
|
||||
@11-16 Apply(
|
||||
@11-16 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@11-16 Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
@11-24 Closure(
|
||||
[
|
||||
@11-16 Identifier {
|
||||
ident: "#!a0",
|
||||
},
|
||||
],
|
||||
@11-16 Apply(
|
||||
@11-16 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@11-16 Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
},
|
||||
@11-16 Closure(
|
||||
[
|
||||
@11-16 RecordDestructure(
|
||||
[],
|
||||
),
|
||||
],
|
||||
@21-24 Var {
|
||||
module_name: "",
|
||||
ident: "bar",
|
||||
},
|
||||
),
|
||||
@11-16 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
BangSuffix,
|
||||
),
|
||||
regions: [
|
||||
@11-16,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @11-16 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
ann_type: @11-16 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@11-16 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@11-16 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@11-16 Inferred,
|
||||
],
|
||||
),
|
||||
@11-16 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @11-16 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
body_expr: @11-16 Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
@11-16 Var {
|
||||
module_name: "",
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
),
|
||||
@11-16 Closure(
|
||||
[
|
||||
@11-16 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@21-24 Var {
|
||||
module_name: "",
|
||||
ident: "bar",
|
||||
},
|
||||
),
|
||||
],
|
||||
BangSuffix,
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -44,7 +46,7 @@ Defs {
|
|||
@15-43 Closure(
|
||||
[
|
||||
Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@15-43 Apply(
|
||||
|
@ -62,7 +64,7 @@ Defs {
|
|||
@21-29 ParensAround(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
),
|
||||
@32-42 ParensAround(
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
|
|
@ -13,17 +13,19 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-3 Identifier {
|
||||
ident: "run",
|
||||
},
|
||||
@0-22 Apply(
|
||||
@0-22 Var {
|
||||
@6-22 Apply(
|
||||
@6-22 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
|
@ -32,14 +34,14 @@ Defs {
|
|||
module_name: "",
|
||||
ident: "nextMsg",
|
||||
},
|
||||
@0-22 Closure(
|
||||
@6-22 Closure(
|
||||
[
|
||||
Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@0-22 Apply(
|
||||
@0-22 Var {
|
||||
@6-22 Apply(
|
||||
@6-22 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
|
@ -47,7 +49,7 @@ Defs {
|
|||
@13-21 ParensAround(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -28,42 +30,86 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@11-56 Apply(
|
||||
@11-56 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@11-56,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @11-57 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
ann_type: @11-57 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@11-57 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@11-57 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @11-57 Identifier {
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
body_expr: @11-56 Apply(
|
||||
@11-56 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@11-44 Apply(
|
||||
@26-36 Var {
|
||||
module_name: "Str",
|
||||
ident: "concat",
|
||||
},
|
||||
[
|
||||
@11-18 Str(
|
||||
PlainLine(
|
||||
"hello",
|
||||
),
|
||||
),
|
||||
@37-44 Str(
|
||||
PlainLine(
|
||||
"world",
|
||||
),
|
||||
),
|
||||
],
|
||||
BinOp(
|
||||
Pizza,
|
||||
),
|
||||
),
|
||||
],
|
||||
BinOp(
|
||||
Pizza,
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
@11-56 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
ident: "#!0_stmt",
|
||||
},
|
||||
[
|
||||
@11-44 Apply(
|
||||
@26-36 Var {
|
||||
module_name: "Str",
|
||||
ident: "concat",
|
||||
},
|
||||
[
|
||||
@11-18 Str(
|
||||
PlainLine(
|
||||
"hello",
|
||||
),
|
||||
),
|
||||
@37-44 Str(
|
||||
PlainLine(
|
||||
"world",
|
||||
),
|
||||
),
|
||||
],
|
||||
BinOp(
|
||||
Pizza,
|
||||
),
|
||||
),
|
||||
],
|
||||
BinOp(
|
||||
Pizza,
|
||||
),
|
||||
),
|
||||
@11-56 Closure(
|
||||
[
|
||||
@26-56 RecordDestructure(
|
||||
[],
|
||||
@11-57 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@63-73 Apply(
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -37,24 +39,68 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@19-30 Apply(
|
||||
@19-30 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@19-30,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @19-30 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
ann_type: @19-30 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@19-30 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@19-30 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @19-30 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
body_expr: @19-30 Apply(
|
||||
@19-30 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@25-30 Str(
|
||||
PlainLine(
|
||||
"FOO",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
@19-30 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
[
|
||||
@25-30 Str(
|
||||
PlainLine(
|
||||
"FOO",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
@19-30 Closure(
|
||||
[
|
||||
@19-30 RecordDestructure(
|
||||
[],
|
||||
@19-30 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@36-67 Apply(
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-44,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-1 Identifier {
|
||||
ident: "f",
|
||||
},
|
||||
@4-44 Closure(
|
||||
[
|
||||
@5-6 Identifier {
|
||||
ident: "x",
|
||||
},
|
||||
],
|
||||
@28-30 Apply(
|
||||
@28-30 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@14-30 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@28-30,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @14-15 Identifier {
|
||||
ident: "#!0_expr",
|
||||
},
|
||||
ann_type: @18-19 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@18-19 Apply(
|
||||
"",
|
||||
"A",
|
||||
[],
|
||||
),
|
||||
@18-19 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @24-25 Identifier {
|
||||
ident: "#!0_expr",
|
||||
},
|
||||
body_expr: @28-30 Var {
|
||||
module_name: "",
|
||||
ident: "x",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
@28-30 Var {
|
||||
module_name: "",
|
||||
ident: "#!0_expr",
|
||||
},
|
||||
),
|
||||
@28-30 Closure(
|
||||
[
|
||||
@24-25 Identifier {
|
||||
ident: "r",
|
||||
},
|
||||
],
|
||||
@35-44 Apply(
|
||||
@35-42 Var {
|
||||
module_name: "Task",
|
||||
ident: "ok",
|
||||
},
|
||||
[
|
||||
@43-44 Var {
|
||||
module_name: "",
|
||||
ident: "r",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
),
|
||||
],
|
||||
BangSuffix,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
}
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -44,27 +46,27 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@24-33 Var {
|
||||
@28-33 Var {
|
||||
module_name: "",
|
||||
ident: "bar",
|
||||
},
|
||||
@15-19 Closure(
|
||||
[
|
||||
@24-33 Identifier {
|
||||
ident: "#!a0",
|
||||
@28-33 Identifier {
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@24-33 Apply(
|
||||
@24-33 Var {
|
||||
@28-33 Apply(
|
||||
@28-33 Var {
|
||||
module_name: "Task",
|
||||
ident: "await",
|
||||
},
|
||||
[
|
||||
@24-33 Var {
|
||||
@28-33 Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
@24-33 Closure(
|
||||
@28-33 Closure(
|
||||
[
|
||||
@24-25 Identifier {
|
||||
ident: "b",
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -35,13 +37,13 @@ Defs {
|
|||
@11-120 Closure(
|
||||
[
|
||||
@16-24 Identifier {
|
||||
ident: "#!a1",
|
||||
ident: "#!2_arg",
|
||||
},
|
||||
],
|
||||
@11-120 When(
|
||||
@16-24 Var {
|
||||
module_name: "",
|
||||
ident: "#!a1",
|
||||
ident: "#!2_arg",
|
||||
},
|
||||
[
|
||||
WhenBranch {
|
||||
|
@ -56,24 +58,68 @@ Defs {
|
|||
ident: "await",
|
||||
},
|
||||
[
|
||||
@54-65 Apply(
|
||||
@54-65 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@54-65,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
AnnotatedBody {
|
||||
ann_pattern: @54-65 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
ann_type: @54-65 Apply(
|
||||
"",
|
||||
"Task",
|
||||
[
|
||||
@54-65 Record {
|
||||
fields: [],
|
||||
ext: None,
|
||||
},
|
||||
@54-65 Inferred,
|
||||
],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @54-65 Identifier {
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
body_expr: @54-65 Apply(
|
||||
@54-65 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
},
|
||||
[
|
||||
@60-65 Str(
|
||||
PlainLine(
|
||||
"foo",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
@54-65 Var {
|
||||
module_name: "",
|
||||
ident: "line",
|
||||
ident: "#!1_stmt",
|
||||
},
|
||||
[
|
||||
@60-65 Str(
|
||||
PlainLine(
|
||||
"foo",
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
@54-65 Closure(
|
||||
[
|
||||
@54-65 RecordDestructure(
|
||||
[],
|
||||
@54-65 Underscore(
|
||||
"#!stmt",
|
||||
),
|
||||
],
|
||||
@78-89 Apply(
|
||||
|
|
|
@ -13,9 +13,11 @@ Defs {
|
|||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
Slice(start = 0, length = 1),
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
|
@ -35,13 +37,13 @@ Defs {
|
|||
@11-74 Closure(
|
||||
[
|
||||
@16-24 Identifier {
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
],
|
||||
@11-74 When(
|
||||
@16-24 Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
},
|
||||
[
|
||||
WhenBranch {
|
||||
|
|
|
@ -382,7 +382,7 @@ mod test_can {
|
|||
let arena = Bump::new();
|
||||
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
|
||||
|
||||
assert_eq!(problems.len(), 0);
|
||||
assert_eq!(problems, Vec::new());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -399,7 +399,7 @@ mod test_can {
|
|||
let arena = Bump::new();
|
||||
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
|
||||
|
||||
assert_eq!(problems.len(), 0);
|
||||
assert_eq!(problems, Vec::new());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -128,7 +128,7 @@ mod suffixed_tests {
|
|||
* Example with a parens suffixed sub-expression
|
||||
* in the function part of an Apply.
|
||||
*
|
||||
* Note how the parens unwraps into an intermediate answer #!a0 instead of
|
||||
* Note how the parens unwraps into an intermediate answer #!0_arg instead of
|
||||
* unwrapping the def `do`.
|
||||
*
|
||||
*/
|
||||
|
@ -162,7 +162,7 @@ mod suffixed_tests {
|
|||
/**
|
||||
* Example with a multiple suffixed Var
|
||||
*
|
||||
* Note it unwraps into an intermediate answer `#!a0`
|
||||
* Note it unwraps into an intermediate answer `#!0_arg`
|
||||
*
|
||||
*/
|
||||
#[test]
|
||||
|
@ -546,43 +546,36 @@ mod suffixed_tests {
|
|||
"##
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn type_annotation() {
|
||||
run_test!(
|
||||
r##"
|
||||
f = \x ->
|
||||
r : A
|
||||
r = x!
|
||||
Task.ok r
|
||||
"##
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_suffixed_helpers {
|
||||
|
||||
use roc_can::suffixed::is_matching_intermediate_answer;
|
||||
use roc_module::called_via::CalledVia;
|
||||
use roc_module::ident::ModuleName;
|
||||
use roc_parse::ast::Expr;
|
||||
use roc_parse::ast::Pattern;
|
||||
use roc_region::all::Loc;
|
||||
|
||||
#[test]
|
||||
fn test_matching_answer() {
|
||||
let loc_pat = Loc::at_zero(Pattern::Identifier { ident: "#!a0" });
|
||||
let loc_pat = Loc::at_zero(Pattern::Identifier { ident: "#!0_arg" });
|
||||
let loc_new = Loc::at_zero(Expr::Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
ident: "#!0_arg",
|
||||
});
|
||||
|
||||
std::assert!(is_matching_intermediate_answer(&loc_pat, &loc_new));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_matching_answer_task_ok() {
|
||||
let loc_pat = Loc::at_zero(Pattern::Identifier { ident: "#!a0" });
|
||||
let intermetiate = &[&Loc::at_zero(Expr::Var {
|
||||
module_name: "",
|
||||
ident: "#!a0",
|
||||
})];
|
||||
let task_ok = Loc::at_zero(Expr::Var {
|
||||
module_name: ModuleName::TASK,
|
||||
ident: "ok",
|
||||
});
|
||||
|
||||
let loc_new = Loc::at_zero(Expr::Apply(&task_ok, intermetiate, CalledVia::BangSuffix));
|
||||
|
||||
std::assert!(is_matching_intermediate_answer(&loc_pat, &loc_new));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue