Remove Task from Roc

This commit is contained in:
Sam Mohr 2025-01-08 16:12:03 -08:00
parent fbf448cac8
commit 2150ee2219
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
139 changed files with 337 additions and 14295 deletions

View file

@ -10,7 +10,6 @@ use crate::annotation::IntroducedVariables;
use crate::annotation::OwnedNamedOrAble;
use crate::derive;
use crate::env::Env;
use crate::env::FxMode;
use crate::expr::canonicalize_record;
use crate::expr::get_lookup_symbols;
use crate::expr::AnnotatedMark;
@ -3265,13 +3264,7 @@ fn to_pending_value_def<'a>(
))
}
StmtAfterExpr => PendingValue::StmtAfterExpr,
Stmt(expr) => {
if env.fx_mode == FxMode::Task {
internal_error!("a Stmt was not desugared correctly, should have been converted to a Body(...) in desguar")
}
PendingValue::Def(PendingValueDef::Stmt(expr))
}
Stmt(expr) => PendingValue::Def(PendingValueDef::Stmt(expr)),
}
}

View file

@ -1,18 +1,16 @@
#![allow(clippy::manual_map)]
use crate::env::{Env, FxMode};
use crate::env::Env;
use crate::scope::Scope;
use crate::suffixed::{apply_try_function, unwrap_suffixed_expression, EUnwrapped};
use bumpalo::collections::Vec;
use bumpalo::Bump;
use roc_error_macros::internal_error;
use roc_module::called_via::BinOp::{DoubleQuestion, Pizza};
use roc_module::called_via::{BinOp, CalledVia};
use roc_module::ident::ModuleName;
use roc_parse::ast::Expr::{self, *};
use roc_parse::ast::{
is_expr_suffixed, AssignedField, Collection, Defs, ModuleImportParams, Pattern, ResultTryKind,
StrLiteral, StrSegment, TryTarget, TypeAnnotation, ValueDef, WhenBranch,
AssignedField, Collection, Defs, ModuleImportParams, Pattern, ResultTryKind,
StrLiteral, StrSegment, ValueDef, WhenBranch,
};
use roc_problem::can::Problem;
use roc_region::all::{Loc, Region};
@ -95,10 +93,7 @@ fn new_op_call_expr<'a>(
),
);
}
TrySuffix {
target: TryTarget::Result,
expr: fn_expr,
} => {
TrySuffix(fn_expr) => {
let loc_fn = env.arena.alloc(Loc::at(right.region, **fn_expr));
let function = desugar_expr(env, scope, loc_fn);
@ -120,10 +115,7 @@ fn new_op_call_expr<'a>(
PncApply(
&Loc {
value:
TrySuffix {
target: TryTarget::Result,
expr: fn_expr,
},
TrySuffix(fn_expr),
region: fn_region,
},
loc_args,
@ -154,11 +146,7 @@ fn new_op_call_expr<'a>(
}
Apply(
&Loc {
value:
TrySuffix {
target: TryTarget::Result,
expr: fn_expr,
},
value: TrySuffix(fn_expr),
region: fn_region,
},
loc_args,
@ -386,46 +374,7 @@ fn desugar_value_def<'a>(
"StmtAfterExpression is only created during desugaring, so it shouldn't exist here."
),
Stmt(stmt_expr) => {
if env.fx_mode == FxMode::PurityInference {
// In purity inference mode, statements aren't fully desugared here
// so we can provide better errors
return Stmt(desugar_expr(env, scope, stmt_expr));
}
// desugar `stmt_expr!` to
// _ : {}
// _ = stmt_expr!
let desugared_expr = desugar_expr(env, scope, stmt_expr);
if !is_expr_suffixed(&desugared_expr.value)
&& !matches!(&desugared_expr.value, LowLevelTry(_, _))
{
env.problems.push(Problem::StmtAfterExpr(stmt_expr.region));
return ValueDef::StmtAfterExpr;
}
let region = stmt_expr.region;
let new_pat = env
.arena
.alloc(Loc::at(region, Pattern::Underscore("#!stmt")));
ValueDef::AnnotatedBody {
ann_pattern: new_pat,
ann_type: env.arena.alloc(Loc::at(
region,
TypeAnnotation::Record {
fields: Collection::empty(),
ext: None,
},
)),
lines_between: &[],
body_pattern: new_pat,
body_expr: desugared_expr,
}
}
Stmt(stmt_expr) => Stmt(desugar_expr(env, scope, stmt_expr)),
}
}
@ -433,147 +382,10 @@ pub fn desugar_defs_node_values<'a>(
env: &mut Env<'a>,
scope: &mut Scope,
defs: &mut roc_parse::ast::Defs<'a>,
top_level_def: bool,
) {
for value_def in defs.value_defs.iter_mut() {
*value_def = desugar_value_def(env, scope, env.arena.alloc(*value_def));
}
// `desugar_defs_node_values` is called recursively in `desugar_expr`
// and we only want to unwrap suffixed nodes if they are a top level def.
//
// check here first so we only unwrap the expressions once, and after they have
// been desugared
if top_level_def {
for value_def in defs.value_defs.iter_mut() {
*value_def = desugar_value_def_suffixed(env.arena, *value_def);
}
}
}
/// For each top-level ValueDef in our module, we will unwrap any suffixed
/// expressions
///
/// e.g. `say! "hi"` desugars to `Task.await (say "hi") \{} -> ...`
pub fn desugar_value_def_suffixed<'a>(arena: &'a Bump, value_def: ValueDef<'a>) -> ValueDef<'a> {
use ValueDef::*;
match value_def {
Body(loc_pattern, loc_expr) => {
// note called_from_def is passed as `false` as this is a top_level_def
match unwrap_suffixed_expression(arena, loc_expr, None) {
Ok(new_expr) => Body(loc_pattern, new_expr),
Err(EUnwrapped::UnwrappedSubExpr {
sub_arg,
sub_pat,
sub_new,
target,
}) => desugar_value_def_suffixed(
arena,
Body(
loc_pattern,
apply_try_function(
arena,
loc_expr.region,
sub_arg,
sub_pat,
sub_new,
None,
target,
),
),
),
Err(..) => Body(
loc_pattern,
arena.alloc(Loc::at(loc_expr.region, MalformedSuffixed(loc_expr))),
),
}
}
ann @ Annotation(_, _) => ann,
AnnotatedBody {
ann_pattern,
ann_type,
lines_between,
body_pattern,
body_expr,
} => {
match unwrap_suffixed_expression(arena, body_expr, Some(ann_pattern)) {
Ok(new_expr) => AnnotatedBody {
ann_pattern,
ann_type,
lines_between,
body_pattern,
body_expr: new_expr,
},
Err(EUnwrapped::UnwrappedSubExpr {
sub_arg,
sub_pat,
sub_new,
target,
}) => desugar_value_def_suffixed(
arena,
AnnotatedBody {
ann_pattern,
ann_type,
lines_between,
body_pattern,
body_expr: apply_try_function(
arena,
body_expr.region,
sub_arg,
sub_pat,
sub_new,
Some((ann_pattern, ann_type)),
target,
),
},
),
// When the last expression is suffixed, it will try to unwrap the def, but because we
// have an annotated def we can simply ignore the try and return it as is without
// creating an intermediate identifier
Err(EUnwrapped::UnwrappedDefExpr { loc_expr, .. }) => desugar_value_def_suffixed(
arena,
AnnotatedBody {
ann_pattern,
ann_type,
lines_between,
body_pattern,
body_expr: loc_expr,
},
),
Err(..) => AnnotatedBody {
ann_pattern,
ann_type,
lines_between,
body_pattern,
body_expr: arena.alloc(Loc::at(body_expr.region, MalformedSuffixed(body_expr))),
},
}
}
Expect {
condition,
preceding_comment,
} => match unwrap_suffixed_expression(arena, condition, None) {
Ok(new_condition) => ValueDef::Expect {
condition: new_condition,
preceding_comment,
},
Err(..) => {
internal_error!("Unable to desugar the suffix inside an Expect value def");
}
},
// TODO support desugaring of Dbg
Dbg { .. } => value_def,
ModuleImport { .. } | IngestedFileImport(_) | StmtAfterExpr => value_def,
Stmt(..) => {
internal_error!(
"this should have been desugared into a Body(..) before this call in desugar_expr"
)
}
}
}
/// Reorder the expression tree based on operator precedence and associativity rules,
@ -588,10 +400,10 @@ pub fn desugar_expr<'a>(
| Num(..)
| NonBase10Int { .. }
| SingleQuote(_)
| Var { .. }
| AccessorFunction(_)
| Underscore { .. }
| MalformedIdent(_, _)
| MalformedSuffixed(..)
| PrecedenceConflict { .. }
| EmptyRecordBuilder(_)
| SingleFieldRecordBuilder(_)
@ -601,23 +413,6 @@ pub fn desugar_expr<'a>(
| Crash
| Try => loc_expr,
Var { module_name, ident } => {
if env.fx_mode == FxMode::Task && ident.ends_with('!') {
env.arena.alloc(Loc::at(
Region::new(loc_expr.region.start(), loc_expr.region.end().sub(1)),
TrySuffix {
expr: env.arena.alloc(Var {
module_name,
ident: ident.trim_end_matches('!'),
}),
target: roc_parse::ast::TryTarget::Task,
},
))
} else {
loc_expr
}
}
Str(str_literal) => match str_literal {
StrLiteral::PlainLine(_) => loc_expr,
StrLiteral::Line(segments) => {
@ -651,32 +446,14 @@ pub fn desugar_expr<'a>(
env.arena.alloc(Loc { region, value })
}
TrySuffix {
expr: sub_expr,
target,
} => {
TrySuffix(sub_expr) => {
let intermediate = env.arena.alloc(Loc::at(loc_expr.region, **sub_expr));
let new_sub_loc_expr = desugar_expr(env, scope, intermediate);
match target {
TryTarget::Result => env.arena.alloc(Loc::at(
loc_expr.region,
LowLevelTry(new_sub_loc_expr, ResultTryKind::OperatorSuffix),
)),
TryTarget::Task => {
let new_sub_expr = env.arena.alloc(new_sub_loc_expr.value);
// desugar the sub_expression, but leave the TrySuffix as this will
// be unwrapped later in desugar_value_def_suffixed
env.arena.alloc(Loc::at(
loc_expr.region,
TrySuffix {
expr: new_sub_expr,
target: *target,
},
))
}
}
env.arena.alloc(Loc::at(
loc_expr.region,
LowLevelTry(new_sub_loc_expr, ResultTryKind::OperatorSuffix),
))
}
RecordAccess(sub_expr, paths) => {
let region = loc_expr.region;
@ -1066,7 +843,7 @@ pub fn desugar_expr<'a>(
BinOps(lefts, right) => desugar_bin_ops(env, scope, loc_expr.region, lefts, right),
Defs(defs, loc_ret) => {
let mut defs = (*defs).clone();
desugar_defs_node_values(env, scope, &mut defs, false);
desugar_defs_node_values(env, scope, &mut defs);
let loc_ret = desugar_expr(env, scope, loc_ret);
env.arena.alloc(Loc::at(
@ -1132,11 +909,7 @@ pub fn desugar_expr<'a>(
}
Apply(
Loc {
value:
TrySuffix {
target: TryTarget::Result,
expr: fn_expr,
},
value: TrySuffix(fn_expr),
region: fn_region,
},
loc_args,

View file

@ -4,15 +4,18 @@ use crate::pattern::Pattern;
use crate::scope::Scope;
use roc_collections::SendMap;
use roc_module::symbol::Symbol;
use roc_problem::can::{Problem, RuntimeError};
use roc_region::all::{Loc, Region};
use roc_types::subs::{VarStore, Variable};
use roc_types::types::{LambdaSet, OptAbleVar, Type};
use roc_types::types::Type;
pub fn build_host_exposed_def(
scope: &mut Scope,
symbol: Symbol,
region: Region,
ident: &str,
var_store: &mut VarStore,
problems: &mut Vec<Problem>,
annotation: crate::annotation::Annotation,
) -> Def {
let expr_var = var_store.fresh();
@ -22,7 +25,6 @@ pub fn build_host_exposed_def(
let mut arguments: Vec<(Variable, AnnotatedMark, Loc<Pattern>)> = Vec::new();
let mut linked_symbol_arguments: Vec<(Variable, Expr)> = Vec::new();
let mut captured_symbols: Vec<(Symbol, Variable)> = Vec::new();
let crate::annotation::Annotation {
introduced_variables,
@ -31,173 +33,57 @@ pub fn build_host_exposed_def(
..
} = annotation;
let def_body = {
match typ.shallow_structural_dealias() {
Type::Function(args, _, _, fx) if **fx == Type::Pure => {
for i in 0..args.len() {
let name = format!("closure_arg_{ident}_{i}");
let foreign_call = match typ.shallow_structural_dealias() {
Type::Function(args, _, _, _) => {
for i in 0..args.len() {
let name = format!("{ident}_arg_{i}");
let arg_symbol = {
let ident = name.clone().into();
scope.introduce(ident, Region::zero()).unwrap()
};
let arg_var = var_store.fresh();
arguments.push((
arg_var,
AnnotatedMark::new(var_store),
Loc::at_zero(Pattern::Identifier(arg_symbol)),
));
captured_symbols.push((arg_symbol, arg_var));
linked_symbol_arguments.push((arg_var, Expr::Var(arg_symbol, arg_var)));
}
let foreign_symbol_name = format!("roc_fx_{ident}");
let low_level_call = Expr::ForeignCall {
foreign_symbol: foreign_symbol_name.into(),
args: linked_symbol_arguments,
ret_var: var_store.fresh(),
};
let task_closure_symbol = {
let name = format!("task_closure_{ident}");
let ident = name.into();
let arg_symbol = {
let ident = name.clone().into();
scope.introduce(ident, Region::zero()).unwrap()
};
let task_closure = Expr::Closure(ClosureData {
function_type: var_store.fresh(),
closure_type: var_store.fresh(),
return_type: var_store.fresh(),
fx_type: var_store.fresh(),
early_returns: vec![],
name: task_closure_symbol,
captured_symbols,
recursive: Recursive::NotRecursive,
arguments: vec![(
var_store.fresh(),
AnnotatedMark::new(var_store),
Loc::at_zero(empty_record_pattern(var_store)),
)],
loc_body: Box::new(Loc::at_zero(low_level_call)),
});
let arg_var = var_store.fresh();
let (specialized_def_type, type_arguments, lambda_set_variables) =
build_fresh_opaque_variables(var_store);
let body = Expr::OpaqueRef {
opaque_var: var_store.fresh(),
name: Symbol::TASK_TASK,
argument: Box::new((var_store.fresh(), Loc::at_zero(task_closure))),
specialized_def_type,
type_arguments,
lambda_set_variables,
};
arguments.push((
arg_var,
AnnotatedMark::new(var_store),
Loc::at_zero(Pattern::Identifier(arg_symbol)),
));
Expr::Closure(ClosureData {
function_type: var_store.fresh(),
closure_type: var_store.fresh(),
return_type: var_store.fresh(),
fx_type: var_store.fresh(),
early_returns: vec![],
name: symbol,
captured_symbols: std::vec::Vec::new(),
recursive: Recursive::NotRecursive,
arguments,
loc_body: Box::new(Loc::at_zero(body)),
})
linked_symbol_arguments.push((arg_var, Expr::Var(arg_symbol, arg_var)));
}
Type::Function(args, _, _, fx) if **fx == Type::Effectful => {
for i in 0..args.len() {
let name = format!("{ident}_arg_{i}");
let arg_symbol = {
let ident = name.clone().into();
scope.introduce(ident, Region::zero()).unwrap()
};
let ident_without_bang = ident.trim_end_matches('!');
let foreign_symbol_name = format!("roc_fx_{ident_without_bang}");
let arg_var = var_store.fresh();
arguments.push((
arg_var,
AnnotatedMark::new(var_store),
Loc::at_zero(Pattern::Identifier(arg_symbol)),
));
linked_symbol_arguments.push((arg_var, Expr::Var(arg_symbol, arg_var)));
}
let ident_without_bang = ident.trim_end_matches('!');
let foreign_symbol_name = format!("roc_fx_{ident_without_bang}");
let foreign_call = Expr::ForeignCall {
foreign_symbol: foreign_symbol_name.into(),
args: linked_symbol_arguments,
ret_var: var_store.fresh(),
};
Expr::Closure(ClosureData {
function_type: var_store.fresh(),
closure_type: var_store.fresh(),
return_type: var_store.fresh(),
fx_type: var_store.fresh(),
early_returns: vec![],
name: symbol,
captured_symbols: std::vec::Vec::new(),
recursive: Recursive::NotRecursive,
arguments,
loc_body: Box::new(Loc::at_zero(foreign_call)),
})
}
_ => {
// not a function
let foreign_symbol_name = format!("roc_fx_{ident}");
let low_level_call = Expr::ForeignCall {
foreign_symbol: foreign_symbol_name.into(),
args: linked_symbol_arguments,
ret_var: var_store.fresh(),
};
let task_closure_symbol = {
let name = format!("task_closure_{ident}");
let ident = name.into();
scope.introduce(ident, Region::zero()).unwrap()
};
let task_closure = Expr::Closure(ClosureData {
function_type: var_store.fresh(),
closure_type: var_store.fresh(),
return_type: var_store.fresh(),
fx_type: var_store.fresh(),
early_returns: vec![],
name: task_closure_symbol,
captured_symbols,
recursive: Recursive::NotRecursive,
arguments: vec![(
var_store.fresh(),
AnnotatedMark::new(var_store),
Loc::at_zero(empty_record_pattern(var_store)),
)],
loc_body: Box::new(Loc::at_zero(low_level_call)),
});
let (specialized_def_type, type_arguments, lambda_set_variables) =
build_fresh_opaque_variables(var_store);
Expr::OpaqueRef {
opaque_var: var_store.fresh(),
name: Symbol::TASK_TASK,
argument: Box::new((var_store.fresh(), Loc::at_zero(task_closure))),
specialized_def_type,
type_arguments,
lambda_set_variables,
}
Expr::ForeignCall {
foreign_symbol: foreign_symbol_name.into(),
args: linked_symbol_arguments,
ret_var: var_store.fresh(),
}
}
_ => {
let runtime_error = RuntimeError::NonFunctionHostedAnnotation(region);
problems.push(Problem::RuntimeError(runtime_error.clone()));
Expr::RuntimeError(runtime_error)
}
};
let def_body = Expr::Closure(ClosureData {
function_type: var_store.fresh(),
closure_type: var_store.fresh(),
return_type: var_store.fresh(),
fx_type: var_store.fresh(),
early_returns: vec![],
name: symbol,
captured_symbols: std::vec::Vec::new(),
recursive: Recursive::NotRecursive,
arguments,
loc_body: Box::new(Loc::at_zero(foreign_call)),
});
let def_annotation = crate::def::Annotation {
signature: typ,
introduced_variables,
@ -214,44 +100,3 @@ pub fn build_host_exposed_def(
kind: DefKind::Let,
}
}
fn build_fresh_opaque_variables(
var_store: &mut VarStore,
) -> (Box<Type>, Vec<OptAbleVar>, Vec<LambdaSet>) {
let closure_var = var_store.fresh();
let ok_var = var_store.fresh();
let err_var = var_store.fresh();
let result_var = var_store.fresh();
let fx_var = var_store.fresh();
let actual = Type::Function(
vec![Type::EmptyRec],
Box::new(Type::Variable(closure_var)),
Box::new(Type::Variable(result_var)),
Box::new(Type::Variable(fx_var)),
);
let type_arguments = vec![
OptAbleVar {
var: ok_var,
opt_abilities: None,
},
OptAbleVar {
var: err_var,
opt_abilities: None,
},
];
let lambda_set_variables = vec![roc_types::types::LambdaSet(Type::Variable(closure_var))];
(Box::new(actual), type_arguments, lambda_set_variables)
}
#[inline(always)]
fn empty_record_pattern(var_store: &mut VarStore) -> Pattern {
Pattern::RecordDestructure {
whole_var: var_store.fresh(),
ext_var: var_store.fresh(),
destructs: vec![],
}
}

View file

@ -42,8 +42,6 @@ pub struct Env<'a> {
pub opt_shorthand: Option<&'a str>,
pub fx_mode: FxMode,
pub src: &'a str,
/// Lazily calculated line info. This data is only needed if the code contains calls to `dbg`,
@ -62,7 +60,6 @@ impl<'a> Env<'a> {
dep_idents: &'a IdentIdsByModule,
qualified_module_ids: &'a PackageModuleIds<'a>,
opt_shorthand: Option<&'a str>,
fx_mode: FxMode,
) -> Env<'a> {
Env {
arena,
@ -79,7 +76,6 @@ impl<'a> Env<'a> {
home_params_record: None,
opt_shorthand,
line_info: arena.alloc(None),
fx_mode,
}
}
@ -234,9 +230,3 @@ impl<'a> Env<'a> {
self.line_info.as_ref().unwrap()
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum FxMode {
PurityInference,
Task,
}

View file

@ -1548,10 +1548,6 @@ pub fn canonicalize_expr<'a>(
(RuntimeError(problem), Output::default())
}
ast::Expr::MalformedSuffixed(..) => {
use roc_problem::can::RuntimeError::*;
(RuntimeError(MalformedSuffixed(region)), Output::default())
}
ast::Expr::EmptyRecordBuilder(sub_expr) => {
use roc_problem::can::RuntimeError::*;
@ -2286,8 +2282,7 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
ast::Expr::Tuple(fields) => fields
.iter()
.all(|loc_field| is_valid_interpolation(&loc_field.value)),
ast::Expr::MalformedSuffixed(loc_expr)
| ast::Expr::EmptyRecordBuilder(loc_expr)
ast::Expr::EmptyRecordBuilder(loc_expr)
| ast::Expr::SingleFieldRecordBuilder(loc_expr)
| ast::Expr::OptionalFieldInRecordBuilder(_, loc_expr)
| ast::Expr::PrecedenceConflict(PrecedenceConflict { expr: loc_expr, .. })
@ -2296,7 +2291,7 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
ast::Expr::TupleAccess(sub_expr, _)
| ast::Expr::ParensAround(sub_expr)
| ast::Expr::RecordAccess(sub_expr, _)
| ast::Expr::TrySuffix { expr: sub_expr, .. } => is_valid_interpolation(sub_expr),
| ast::Expr::TrySuffix(sub_expr) => is_valid_interpolation(sub_expr),
ast::Expr::Apply(loc_expr, args, _called_via) => {
is_valid_interpolation(&loc_expr.value)
&& args

View file

@ -24,7 +24,6 @@ pub mod num;
pub mod pattern;
pub mod procedure;
pub mod scope;
pub mod suffixed;
pub mod traverse;
pub use derive::DERIVED_REGION;

View file

@ -4,7 +4,7 @@ use crate::abilities::{AbilitiesStore, ImplKey, PendingAbilitiesStore, ResolvedI
use crate::annotation::{canonicalize_annotation, AnnotationFor};
use crate::def::{canonicalize_defs, report_unused_imports, Def, DefKind};
use crate::desugar::desugar_record_destructures;
use crate::env::{Env, FxMode};
use crate::env::Env;
use crate::expr::{ClosureData, Declarations, ExpectLookup, Expr, Output, PendingDerives};
use crate::pattern::{
canonicalize_record_destructs, BindingsFromPattern, Pattern, PermitShadows, RecordDestruct,
@ -224,7 +224,6 @@ pub fn canonicalize_module_defs<'a>(
symbols_from_requires: &[(Loc<Symbol>, Loc<TypeAnnotation<'a>>)],
var_store: &mut VarStore,
opt_shorthand: Option<&'a str>,
fx_mode: FxMode,
) -> ModuleOutput {
let mut can_exposed_imports = MutMap::default();
@ -246,7 +245,6 @@ pub fn canonicalize_module_defs<'a>(
dep_idents,
qualified_module_ids,
opt_shorthand,
fx_mode,
);
for (name, alias) in aliases.into_iter() {
@ -268,7 +266,7 @@ pub fn canonicalize_module_defs<'a>(
// operators, and then again on *their* nested operators, ultimately applying the
// rules multiple times unnecessarily.
crate::desugar::desugar_defs_node_values(&mut env, &mut scope, loc_defs, true);
crate::desugar::desugar_defs_node_values(&mut env, &mut scope, loc_defs);
let mut rigid_variables = RigidVariables::default();
@ -535,7 +533,13 @@ pub fn canonicalize_module_defs<'a>(
};
let hosted_def = crate::effect_module::build_host_exposed_def(
&mut scope, *symbol, &ident, var_store, annotation,
&mut scope,
*symbol,
def_annotation.region,
&ident,
var_store,
&mut env.problems,
annotation,
);
declarations.update_builtin_def(index, hosted_def);
@ -588,7 +592,13 @@ pub fn canonicalize_module_defs<'a>(
};
let hosted_def = crate::effect_module::build_host_exposed_def(
&mut scope, *symbol, &ident, var_store, annotation,
&mut scope,
*symbol,
def_annotation.region,
&ident,
var_store,
&mut env.problems,
annotation,
);
declarations.update_builtin_def(index, hosted_def);

File diff suppressed because it is too large Load diff

View file

@ -56,7 +56,6 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
&dep_idents,
&qualified_module_ids,
None,
roc_can::env::FxMode::PurityInference,
);
// Desugar operators (convert them to Apply calls, taking into account

View file

@ -1,116 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-28,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@15-22 Apply(
@15-22 Var {
module_name: "Task",
ident: "await",
},
[
@17-18 Var {
module_name: "",
ident: "a",
},
@15-22 Closure(
[
@17-18 Identifier {
ident: "#!0_arg",
},
],
@15-22 Apply(
@15-22 Var {
module_name: "Task",
ident: "await",
},
[
@20-21 Var {
module_name: "",
ident: "x",
},
@15-22 Closure(
[
@20-21 Identifier {
ident: "#!1_arg",
},
],
@15-22 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@15-22,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-12 Identifier {
ident: "c",
},
@15-22 Apply(
@15-16 Var {
module_name: "",
ident: "b",
},
[
@17-18 Var {
module_name: "",
ident: "#!0_arg",
},
@20-21 Var {
module_name: "",
ident: "#!1_arg",
},
],
Space,
),
),
],
},
@27-28 Var {
module_name: "",
ident: "c",
},
),
),
],
BangSuffix,
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,92 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-25,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@15-19 Apply(
@15-19 Var {
module_name: "Task",
ident: "await",
},
[
@17-18 Var {
module_name: "",
ident: "a",
},
@15-19 Closure(
[
@17-18 Identifier {
ident: "#!0_arg",
},
],
@15-19 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@15-19,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-12 Identifier {
ident: "c",
},
@15-19 Apply(
@15-16 Var {
module_name: "",
ident: "b",
},
[
@17-18 Var {
module_name: "",
ident: "#!0_arg",
},
],
Space,
),
),
],
},
@24-25 Var {
module_name: "",
ident: "c",
},
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,113 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-43,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@15-33 Apply(
@15-33 Var {
module_name: "Task",
ident: "await",
},
[
Apply(
Var {
module_name: "",
ident: "foo",
},
[
@25-32 Str(
PlainLine(
"hello",
),
),
],
Space,
),
@15-33 Closure(
[
Identifier {
ident: "#!0_arg",
},
],
@15-33 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@15-33,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-12 Identifier {
ident: "x",
},
@15-33 Apply(
@15-18 Var {
module_name: "",
ident: "bar",
},
[
@20-32 ParensAround(
Var {
module_name: "",
ident: "#!0_arg",
},
),
],
Space,
),
),
],
},
@38-43 Apply(
@38-41 Var {
module_name: "",
ident: "baz",
},
[
@42-43 Var {
module_name: "",
ident: "x",
},
],
Space,
),
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,114 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-45,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@15-35 Apply(
@15-35 Var {
module_name: "Task",
ident: "await",
},
[
Apply(
Var {
module_name: "",
ident: "foo",
},
[
@21-26 Str(
PlainLine(
"bar",
),
),
],
Space,
),
@15-35 Closure(
[
Identifier {
ident: "#!0_arg",
},
],
@15-35 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@15-35,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-12 Identifier {
ident: "x",
},
@15-35 Apply(
@16-26 ParensAround(
Var {
module_name: "",
ident: "#!0_arg",
},
),
[
@28-35 Str(
PlainLine(
"hello",
),
),
],
Space,
),
),
],
},
@40-45 Apply(
@40-43 Var {
module_name: "",
ident: "baz",
},
[
@44-45 Var {
module_name: "",
ident: "x",
},
],
Space,
),
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,94 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-28,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@15-22 Apply(
@15-22 Var {
module_name: "Task",
ident: "await",
},
[
@15-16 Var {
module_name: "",
ident: "a",
},
@15-22 Closure(
[
@15-16 Identifier {
ident: "#!0_arg",
},
],
@15-22 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@15-22,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-12 Identifier {
ident: "c",
},
@15-22 Apply(
@21-22 Var {
module_name: "",
ident: "b",
},
[
@15-16 Var {
module_name: "",
ident: "#!0_arg",
},
],
BinOp(
Pizza,
),
),
),
],
},
@27-28 Var {
module_name: "",
ident: "c",
},
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,106 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-26,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-14 Apply(
@11-14 Var {
module_name: "Task",
ident: "await",
},
[
@11-14 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@11-14,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
body_pattern: @11-15 Identifier {
ident: "#!0_stmt",
},
body_expr: @11-14 Var {
module_name: "",
ident: "foo",
},
},
],
},
@11-14 Var {
module_name: "",
ident: "#!0_stmt",
},
),
@11-14 Closure(
[
@11-15 Underscore(
"#!stmt",
),
],
@21-26 Apply(
@21-23 Var {
module_name: "",
ident: "ok",
},
[
@24-26 Record(
[],
),
],
Space,
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,95 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-42,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@16-35 Apply(
@16-35 Var {
module_name: "Task",
ident: "await",
},
[
Var {
module_name: "",
ident: "sayMultiple",
},
@16-35 Closure(
[
Identifier {
ident: "#!0_arg",
},
],
@16-35 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@16-35,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-13 Identifier {
ident: "do",
},
@16-35 Apply(
@17-29 ParensAround(
Var {
module_name: "",
ident: "#!0_arg",
},
),
[
@31-35 Str(
PlainLine(
"hi",
),
),
],
Space,
),
),
],
},
@40-42 Var {
module_name: "",
ident: "do",
},
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,163 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-69,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-69 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@15-57,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-12 Identifier {
ident: "x",
},
@15-57 Closure(
[
@16-19 Identifier {
ident: "msg",
},
],
@31-43 Apply(
@31-43 Var {
module_name: "Task",
ident: "await",
},
[
@31-43 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@31-43,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
body_pattern: @31-43 Identifier {
ident: "#!0_stmt",
},
body_expr: @31-43 Apply(
@31-43 Var {
module_name: "",
ident: "line",
},
[
@31-34 Var {
module_name: "",
ident: "msg",
},
],
BinOp(
Pizza,
),
),
},
],
},
@31-43 Var {
module_name: "",
ident: "#!0_stmt",
},
),
@31-43 Closure(
[
@31-43 Underscore(
"#!stmt",
),
],
@52-57 Apply(
@52-54 Var {
module_name: "",
ident: "ok",
},
[
@55-57 Record(
[],
),
],
Space,
),
),
],
BangSuffix,
),
),
),
],
},
@63-69 Apply(
@63-64 Var {
module_name: "",
ident: "x",
},
[
@65-69 Str(
PlainLine(
"hi",
),
),
],
Space,
),
),
),
],
}

View file

@ -1,164 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-114,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-114 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@39-101,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
AnnotatedBody {
ann_pattern: @11-12 Identifier {
ident: "x",
},
ann_type: @15-30 Function(
[
@15-18 Apply(
"",
"Str",
[],
),
],
Pure,
@22-30 Apply(
"",
"Task",
[
@27-28 Inferred,
@29-30 Inferred,
],
),
),
lines_between: [
Newline,
],
body_pattern: @35-36 Identifier {
ident: "x",
},
body_expr: @39-101 Closure(
[
@40-43 Identifier {
ident: "msg",
},
],
@56-91 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@82-91,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
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",
},
),
),
},
],
},
@107-114 Apply(
@107-108 Var {
module_name: "",
ident: "x",
},
[
@109-114 Str(
PlainLine(
"foo",
),
),
],
Space,
),
),
),
],
}

View file

@ -1,288 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-143,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@12-143 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@56-119,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
AnnotatedBody {
ann_pattern: @12-15 Identifier {
ident: "foo",
},
ann_type: @18-45 Function(
[
@18-21 Apply(
"",
"Str",
[],
),
@23-25 Record {
fields: [],
ext: None,
},
@27-30 Apply(
"",
"Str",
[],
),
],
Pure,
@34-45 Apply(
"",
"Task",
[
@39-41 Record {
fields: [],
ext: None,
},
@42-45 Apply(
"",
"I32",
[],
),
],
),
),
lines_between: [
Newline,
],
body_pattern: @50-53 Identifier {
ident: "foo",
},
body_expr: @56-119 Closure(
[
@57-58 Identifier {
ident: "a",
},
@60-61 Underscore(
"",
),
@63-64 Identifier {
ident: "b",
},
],
@76-83 Apply(
@76-83 Var {
module_name: "Task",
ident: "await",
},
[
@76-83 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@76-83,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
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: "#!1_stmt",
},
),
@76-83 Closure(
[
@76-83 Underscore(
"#!stmt",
),
],
@92-99 Apply(
@92-99 Var {
module_name: "Task",
ident: "await",
},
[
@92-99 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@92-99,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
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: "#!0_stmt",
},
),
@92-99 Closure(
[
@92-99 Underscore(
"#!stmt",
),
],
@109-119 Apply(
@109-116 Var {
module_name: "Task",
ident: "ok",
},
[
@117-119 Record(
[],
),
],
Space,
),
),
],
BangSuffix,
),
),
],
BangSuffix,
),
),
},
],
},
@125-143 Apply(
@125-128 Var {
module_name: "",
ident: "foo",
},
[
@129-134 Str(
PlainLine(
"bar",
),
),
@135-137 Record(
[],
),
@138-143 Str(
PlainLine(
"baz",
),
),
],
Space,
),
),
),
],
}

View file

@ -1,147 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-28,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-28 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@16-27,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@16-27 Identifier {
ident: "1",
},
@16-27 ParensAround(
Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@21-26,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@21-26 Identifier {
ident: "0",
},
@21-26 ParensAround(
Apply(
@23-24 Var {
module_name: "Num",
ident: "add",
},
[
@21-22 Num(
"1",
),
@25-26 Num(
"1",
),
],
BinOp(
Plus,
),
),
),
),
],
},
@16-27 LowLevelDbg(
(
"test.roc:3",
" ",
),
@21-26 Apply(
@21-26 Var {
module_name: "Inspect",
ident: "to_str",
},
[
@21-26 Var {
module_name: "",
ident: "0",
},
],
Space,
),
@21-26 Var {
module_name: "",
ident: "0",
},
),
),
),
),
],
},
@11-28 LowLevelDbg(
(
"test.roc:2",
"n =\n ",
),
@16-27 Apply(
@16-27 Var {
module_name: "Inspect",
ident: "to_str",
},
[
@16-27 Var {
module_name: "",
ident: "1",
},
],
Space,
),
@16-27 Var {
module_name: "",
ident: "1",
},
),
),
),
],
}

View file

@ -1,82 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-49,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@17-23 Apply(
@17-23 Var {
module_name: "Task",
ident: "await",
},
[
@17-23 Var {
module_name: "",
ident: "getFoo",
},
@17-23 Closure(
[
@11-14 Identifier {
ident: "foo",
},
],
@29-36 LowLevelDbg(
(
"test.roc:3",
" ",
),
@33-36 Apply(
@33-36 Var {
module_name: "Inspect",
ident: "to_str",
},
[
@33-36 Var {
module_name: "",
ident: "foo",
},
],
Space,
),
@41-49 Apply(
@41-49 Var {
module_name: "",
ident: "bar",
},
[
@46-49 Var {
module_name: "",
ident: "foo",
},
],
Space,
),
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,73 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-24,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-17 Apply(
@11-17 Var {
module_name: "Task",
ident: "await",
},
[
@15-16 Var {
module_name: "",
ident: "a",
},
@11-17 Closure(
[
@15-16 Identifier {
ident: "#!0_arg",
},
],
@11-17 LowLevelDbg(
(
"test.roc:2",
"i",
),
@15-16 Apply(
@15-16 Var {
module_name: "Inspect",
ident: "to_str",
},
[
@15-16 Var {
module_name: "",
ident: "#!0_arg",
},
],
Space,
),
@23-24 Var {
module_name: "",
ident: "b",
},
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,66 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-99,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-99 When(
@16-17 Var {
module_name: "",
ident: "a",
},
[
WhenBranch {
patterns: [
@29-30 NumLiteral(
"0",
),
],
value: @46-99 When(
@51-52 Var {
module_name: "",
ident: "b",
},
[
WhenBranch {
patterns: [
@72-73 NumLiteral(
"1",
),
],
value: @97-98 Var {
module_name: "",
ident: "c",
},
guard: None,
},
],
),
guard: None,
},
],
),
),
],
}

View file

@ -1,191 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
EitherIndex(2147483649),
],
regions: [
@0-54,
@56-98,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 2 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 1 },
],
spaces: [
Newline,
Newline,
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-54 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@15-20,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-12 Identifier {
ident: "a",
},
@15-20 Str(
PlainLine(
"Foo",
),
),
),
],
},
@11-54 Apply(
@11-54 Var {
module_name: "Task",
ident: "await",
},
[
@25-39 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@25-39,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
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",
},
),
@11-54 Closure(
[
@25-39 Underscore(
"#!stmt",
),
],
@45-53 Var {
module_name: "",
ident: "printBar",
},
),
],
BangSuffix,
),
),
),
Body(
@56-64 Identifier {
ident: "printBar",
},
@71-98 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@75-80,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@71-72 Identifier {
ident: "b",
},
@75-80 Str(
PlainLine(
"Bar",
),
),
),
],
},
@85-98 Apply(
@85-96 Var {
module_name: "Stdout",
ident: "line",
},
[
@97-98 Var {
module_name: "",
ident: "b",
},
],
Space,
),
),
),
],
}

View file

@ -1,105 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-158,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-158 When(
@16-17 Var {
module_name: "",
ident: "x",
},
[
WhenBranch {
patterns: [
@29-30 Tag(
"A",
),
],
value: @46-130 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@50-52,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@46-47 Identifier {
ident: "y",
},
@50-52 Num(
"42",
),
),
],
},
@66-130 If {
if_thens: [
(
@69-70 Var {
module_name: "",
ident: "a",
},
@92-93 Var {
module_name: "",
ident: "b",
},
),
],
final_else: @128-129 Var {
module_name: "",
ident: "c",
},
indented_else: false,
},
),
guard: None,
},
WhenBranch {
patterns: [
@139-140 Tag(
"B",
),
],
value: @156-157 Var {
module_name: "",
ident: "d",
},
guard: None,
},
],
),
),
],
}

View file

@ -1,74 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-31,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-31 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@11-24,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Expect {
condition: @18-24 Apply(
@20-22 Var {
module_name: "Bool",
ident: "is_eq",
},
[
@18-19 Num(
"1",
),
@23-24 Num(
"2",
),
],
BinOp(
Equals,
),
),
preceding_comment: @11-11,
},
],
},
@29-30 Var {
module_name: "",
ident: "x",
},
),
),
],
}

View file

@ -1,406 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-307,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-307 Defs(
Defs {
tags: [
EitherIndex(2147483648),
EitherIndex(2147483649),
EitherIndex(2147483650),
],
regions: [
@20-37,
@53-68,
@109-298,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
Slice<roc_parse::ast::CommentOrNewline> { start: 1, length: 1 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 1, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 0 },
],
spaces: [
Newline,
Newline,
],
type_defs: [],
value_defs: [
Body(
@11-17 Identifier {
ident: "isTrue",
},
@20-37 Apply(
@20-27 Var {
module_name: "Task",
ident: "ok",
},
[
@28-37 Var {
module_name: "Bool",
ident: "true",
},
],
Space,
),
),
Body(
@42-50 Identifier {
ident: "isFalsey",
},
@53-68 Closure(
[
@54-55 Identifier {
ident: "x",
},
],
@59-68 Apply(
@59-66 Var {
module_name: "Task",
ident: "ok",
},
[
@67-68 Var {
module_name: "",
ident: "x",
},
],
Space,
),
),
),
AnnotatedBody {
ann_pattern: @73-76 Identifier {
ident: "msg",
},
ann_type: @79-90 Apply(
"",
"Task",
[
@84-86 Record {
fields: [],
ext: None,
},
@87-90 Apply(
"",
"I32",
[],
),
],
),
lines_between: [
Newline,
],
body_pattern: @95-98 Identifier {
ident: "msg",
},
body_expr: Apply(
Var {
module_name: "Task",
ident: "await",
},
[
Var {
module_name: "",
ident: "isTrue",
},
Closure(
[
Identifier {
ident: "#!1_arg",
},
],
@109-298 If {
if_thens: [
(
@112-122 Apply(
@112-113 Var {
module_name: "Bool",
ident: "not",
},
[
@114-121 ParensAround(
Var {
module_name: "",
ident: "#!1_arg",
},
),
],
UnaryOp(
Not,
),
),
@140-152 Apply(
@140-152 Var {
module_name: "Task",
ident: "await",
},
[
@140-152 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@140-152,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
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: "#!0_stmt",
},
),
@140-152 Closure(
[
@140-152 Underscore(
"#!stmt",
),
],
@165-170 Apply(
@165-168 Var {
module_name: "",
ident: "err",
},
[
@169-170 Num(
"1",
),
],
Space,
),
),
],
BangSuffix,
),
),
],
final_else: Apply(
Var {
module_name: "Task",
ident: "await",
},
[
Apply(
Var {
module_name: "",
ident: "isFalsey",
},
[
@198-208 Var {
module_name: "Bool",
ident: "false",
},
],
Space,
),
Closure(
[
Identifier {
ident: "#!3_arg",
},
],
@109-298 If {
if_thens: [
(
@187-209 ParensAround(
Var {
module_name: "",
ident: "#!3_arg",
},
),
@227-239 Apply(
@227-239 Var {
module_name: "Task",
ident: "await",
},
[
@227-239 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@227-239,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
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: "#!2_stmt",
},
),
@227-239 Closure(
[
@227-239 Underscore(
"#!stmt",
),
],
@252-257 Apply(
@252-254 Var {
module_name: "",
ident: "ok",
},
[
@255-257 Record(
[],
),
],
Space,
),
),
],
BangSuffix,
),
),
],
final_else: @283-298 Apply(
@283-298 Var {
module_name: "",
ident: "line",
},
[
@289-298 Str(
PlainLine(
"success",
),
),
],
Space,
),
indented_else: false,
},
),
],
BangSuffix,
),
indented_else: false,
},
),
],
BangSuffix,
),
},
],
},
@304-307 Var {
module_name: "",
ident: "msg",
},
),
),
],
}

View file

@ -1,196 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-189,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-189 Defs(
Defs {
tags: [
EitherIndex(2147483648),
EitherIndex(2147483649),
],
regions: [
@20-37,
@52-70,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 1, length: 0 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@11-17 Identifier {
ident: "isTrue",
},
@20-37 Apply(
@20-27 Var {
module_name: "Task",
ident: "ok",
},
[
@28-37 Var {
module_name: "Bool",
ident: "true",
},
],
Space,
),
),
Body(
@42-49 Identifier {
ident: "isFalse",
},
@52-70 Apply(
@52-59 Var {
module_name: "Task",
ident: "ok",
},
[
@60-70 Var {
module_name: "Bool",
ident: "false",
},
],
Space,
),
),
],
},
@79-86 Apply(
@79-86 Var {
module_name: "Task",
ident: "await",
},
[
@79-86 Var {
module_name: "",
ident: "isFalse",
},
@79-86 Closure(
[
@79-86 Identifier {
ident: "#!0_arg",
},
],
@76-189 If {
if_thens: [
(
@79-86 Var {
module_name: "",
ident: "#!0_arg",
},
@101-112 Apply(
@101-105 Var {
module_name: "",
ident: "line",
},
[
@106-112 Str(
PlainLine(
"fail",
),
),
],
Space,
),
),
],
final_else: @125-131 Apply(
@125-131 Var {
module_name: "Task",
ident: "await",
},
[
@125-131 Var {
module_name: "",
ident: "isTrue",
},
@125-131 Closure(
[
@125-131 Identifier {
ident: "#!1_arg",
},
],
@76-189 If {
if_thens: [
(
@125-131 Var {
module_name: "",
ident: "#!1_arg",
},
@146-160 Apply(
@146-150 Var {
module_name: "",
ident: "line",
},
[
@151-160 Str(
PlainLine(
"success",
),
),
],
Space,
),
),
],
final_else: @178-189 Apply(
@178-182 Var {
module_name: "",
ident: "line",
},
[
@183-189 Str(
PlainLine(
"fail",
),
),
],
Space,
),
indented_else: false,
},
),
],
BangSuffix,
),
indented_else: false,
},
),
],
BangSuffix,
),
),
),
],
}

View file

@ -1,281 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
EitherIndex(2147483649),
EitherIndex(2147483650),
],
regions: [
@0-80,
@82-227,
@229-266,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 2 },
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 2 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 4, length: 1 },
],
spaces: [
Newline,
Newline,
Newline,
Newline,
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-3 Identifier {
ident: "inc",
},
@6-80 Closure(
[
@7-8 Identifier {
ident: "i",
},
],
@16-80 If {
if_thens: [
(
@19-24 Apply(
@21-22 Var {
module_name: "Num",
ident: "is_gt",
},
[
@19-20 Var {
module_name: "",
ident: "i",
},
@23-24 Num(
"2",
),
],
BinOp(
GreaterThan,
),
),
@38-52 Apply(
@38-41 Tag(
"Err",
),
[
@42-52 Tag(
"MaxReached",
),
],
Space,
),
),
],
final_else: @70-80 Apply(
@70-72 Tag(
"Ok",
),
[
@74-79 ParensAround(
Apply(
@76-77 Var {
module_name: "Num",
ident: "add",
},
[
@74-75 Var {
module_name: "",
ident: "i",
},
@78-79 Num(
"1",
),
],
BinOp(
Plus,
),
),
),
],
Space,
),
indented_else: false,
},
),
),
Expect {
condition: @93-227 Defs(
Defs {
tags: [
EitherIndex(2147483648),
EitherIndex(2147483649),
],
regions: [
@99-189,
@203-208,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 1, length: 0 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@93-96 Identifier {
ident: "run",
},
@99-189 Closure(
[
@100-101 Identifier {
ident: "i",
},
],
@113-189 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@132-172,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@113-117 Identifier {
ident: "newi",
},
@132-172 LowLevelTry(
@132-172 Apply(
@169-172 Var {
module_name: "",
ident: "inc",
},
[
@132-152 LowLevelTry(
@132-152 Apply(
@149-152 Var {
module_name: "",
ident: "inc",
},
[
@132-133 Var {
module_name: "",
ident: "i",
},
],
Try,
),
OperatorSuffix,
),
],
Try,
),
OperatorSuffix,
),
),
],
},
@182-189 Apply(
@182-184 Tag(
"Ok",
),
[
@185-189 Var {
module_name: "",
ident: "newi",
},
],
Space,
),
),
),
),
Body(
@194-200 Identifier {
ident: "result",
},
@203-208 Apply(
@203-206 Var {
module_name: "",
ident: "run",
},
[
@207-208 Num(
"0",
),
],
Space,
),
),
],
},
@213-227 Apply(
@220-222 Var {
module_name: "Bool",
ident: "is_eq",
},
[
@213-219 Var {
module_name: "",
ident: "result",
},
@223-227 Apply(
@223-225 Tag(
"Ok",
),
[
@226-227 Num(
"2",
),
],
Space,
),
],
BinOp(
Equals,
),
),
),
preceding_comment: @82-82,
},
Body(
@229-233 Identifier {
ident: "main",
},
@240-266 Apply(
@240-266 Var {
module_name: "Stdout",
ident: "line",
},
[
@253-266 Str(
PlainLine(
"Hello world",
),
),
],
Space,
),
),
],
}

View file

@ -1,76 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
EitherIndex(2147483649),
],
regions: [
@0-33,
@35-45,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 2 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 1 },
],
spaces: [
Newline,
Newline,
Newline,
],
type_defs: [],
value_defs: [
AnnotatedBody {
ann_pattern: @0-3 Identifier {
ident: "run",
},
ann_type: @6-15 Apply(
"",
"Task",
[
@11-13 Record {
fields: [],
ext: None,
},
@14-15 Inferred,
],
),
lines_between: [
Newline,
],
body_pattern: @16-19 Identifier {
ident: "run",
},
body_expr: @22-33 Apply(
@22-33 Var {
module_name: "",
ident: "line",
},
[
@28-33 Str(
PlainLine(
"foo",
),
),
],
Space,
),
},
Body(
@35-39 Identifier {
ident: "main",
},
@42-45 Var {
module_name: "",
ident: "run",
},
),
],
}

View file

@ -1,91 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-26,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-26 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@15-17,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-12 Identifier {
ident: "x",
},
@15-17 Num(
"42",
),
),
],
},
@11-26 Apply(
@11-26 Var {
module_name: "Task",
ident: "await",
},
[
@24-25 Var {
module_name: "",
ident: "b",
},
@11-26 Closure(
[
@24-25 Identifier {
ident: "#!0_arg",
},
],
@22-26 Apply(
@22-23 Var {
module_name: "",
ident: "a",
},
[
@24-25 Var {
module_name: "",
ident: "#!0_arg",
},
],
Space,
),
),
],
BangSuffix,
),
),
),
],
}

View file

@ -1,162 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-33,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-14 Apply(
@11-14 Var {
module_name: "Task",
ident: "await",
},
[
@11-14 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@11-14,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
body_pattern: @11-15 Identifier {
ident: "#!2_stmt",
},
body_expr: @11-14 Var {
module_name: "",
ident: "foo",
},
},
],
},
@11-14 Var {
module_name: "",
ident: "#!2_stmt",
},
),
@11-14 Closure(
[
@11-15 Underscore(
"#!stmt",
),
],
@20-23 Apply(
@20-23 Var {
module_name: "Task",
ident: "await",
},
[
@20-23 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@20-23,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
body_pattern: @20-24 Identifier {
ident: "#!1_stmt",
},
body_expr: @20-23 Var {
module_name: "",
ident: "bar",
},
},
],
},
@20-23 Var {
module_name: "",
ident: "#!1_stmt",
},
),
@20-23 Closure(
[
@20-24 Underscore(
"#!stmt",
),
],
@29-32 Var {
module_name: "",
ident: "baz",
},
),
],
BangSuffix,
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,52 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-26,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@7-26 Apply(
@7-26 Var {
module_name: "",
ident: "foo",
},
[
@12-17 Str(
PlainLine(
"bar",
),
),
@18-20 Record(
[],
),
@21-26 Str(
PlainLine(
"baz",
),
),
],
Space,
),
),
],
}

View file

@ -1,148 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-72,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-23 Apply(
@11-23 Var {
module_name: "Task",
ident: "await",
},
[
@11-23 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@11-23,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
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: "#!0_stmt",
},
),
@11-23 Closure(
[
@11-23 Underscore(
"#!stmt",
),
],
@33-56 Apply(
@33-56 Var {
module_name: "Task",
ident: "await",
},
[
@33-56 Apply(
@33-56 Var {
module_name: "Stdout",
ident: "line",
},
[
@33-40 Str(
PlainLine(
"There",
),
),
],
BinOp(
Pizza,
),
),
@33-56 Closure(
[
@28-30 RecordDestructure(
[],
),
],
@62-72 Apply(
@62-69 Var {
module_name: "Task",
ident: "ok",
},
[
@70-72 Record(
[],
),
],
Space,
),
),
],
BangSuffix,
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,102 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-51,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-51 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@17-24,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-14 Identifier {
ident: "msg",
},
@17-24 Str(
PlainLine(
"hello",
),
),
),
],
},
@11-51 Apply(
@11-51 Var {
module_name: "Task",
ident: "await",
},
[
@33-41 Apply(
@33-41 Var {
module_name: "",
ident: "foo",
},
[
@38-41 Var {
module_name: "",
ident: "msg",
},
],
Space,
),
@11-51 Closure(
[
@29-30 Identifier {
ident: "x",
},
],
@46-51 Apply(
@46-49 Var {
module_name: "",
ident: "bar",
},
[
@50-51 Var {
module_name: "",
ident: "x",
},
],
Space,
),
),
],
BangSuffix,
),
),
),
],
}

View file

@ -1,105 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-24,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-16 Apply(
@11-16 Var {
module_name: "Task",
ident: "await",
},
[
@11-16 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@11-16,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
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,
),
),
],
}

View file

@ -1,118 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-61,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@15-43 Apply(
@15-43 Var {
module_name: "Task",
ident: "await",
},
[
Apply(
Var {
module_name: "",
ident: "bar",
},
[
@26-29 Var {
module_name: "",
ident: "baz",
},
],
Space,
),
@15-43 Closure(
[
Identifier {
ident: "#!0_arg",
},
],
@15-43 Apply(
@15-43 Var {
module_name: "Task",
ident: "await",
},
[
@15-43 Apply(
@15-43 Var {
module_name: "",
ident: "foo",
},
[
@21-29 ParensAround(
Var {
module_name: "",
ident: "#!0_arg",
},
),
@32-42 ParensAround(
Apply(
@32-36 Var {
module_name: "",
ident: "blah",
},
[
@37-42 Var {
module_name: "",
ident: "stuff",
},
],
Space,
),
),
],
Space,
),
@15-43 Closure(
[
@11-12 Identifier {
ident: "z",
},
],
@48-61 Apply(
@48-59 Var {
module_name: "",
ident: "doSomething",
},
[
@60-61 Var {
module_name: "",
ident: "z",
},
],
Space,
),
),
],
BangSuffix,
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,92 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-49,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-49 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@23-42,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-12 Identifier {
ident: "x",
},
@27-28 Apply(
@27-28 Var {
module_name: "Task",
ident: "await",
},
[
@27-28 Var {
module_name: "",
ident: "b",
},
@27-28 Closure(
[
@23-24 Identifier {
ident: "a",
},
],
@38-42 Apply(
@38-42 Var {
module_name: "",
ident: "c",
},
[
@41-42 Var {
module_name: "",
ident: "a",
},
],
Space,
),
),
],
BangSuffix,
),
),
],
},
@48-49 Var {
module_name: "",
ident: "x",
},
),
),
],
}

View file

@ -1,65 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-22,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-3 Identifier {
ident: "run",
},
@6-22 Apply(
@6-22 Var {
module_name: "Task",
ident: "await",
},
[
Var {
module_name: "",
ident: "nextMsg",
},
@6-22 Closure(
[
Identifier {
ident: "#!0_arg",
},
],
@6-22 Apply(
@6-22 Var {
module_name: "",
ident: "line",
},
[
@13-21 ParensAround(
Var {
module_name: "",
ident: "#!0_arg",
},
),
],
Space,
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,143 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-51,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-51 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@11-40,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-40 Identifier {
ident: "1",
},
@11-40 Apply(
@31-38 Var {
module_name: "Num",
ident: "add",
},
[
@11-23 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@11-12,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-12 Identifier {
ident: "0",
},
@11-12 Num(
"1",
),
),
],
},
@11-23 LowLevelDbg(
(
"test.roc:2",
" ",
),
@11-12 Apply(
@11-12 Var {
module_name: "Inspect",
ident: "to_str",
},
[
@11-12 Var {
module_name: "",
ident: "0",
},
],
Space,
),
@11-12 Var {
module_name: "",
ident: "0",
},
),
),
@39-40 Num(
"2",
),
],
BinOp(
Pizza,
),
),
),
],
},
@11-51 LowLevelDbg(
(
"test.roc:2",
" main =\n 1\n ",
),
@11-40 Apply(
@11-40 Var {
module_name: "Inspect",
ident: "to_str",
},
[
@11-40 Var {
module_name: "",
ident: "1",
},
],
Space,
),
@11-40 Var {
module_name: "",
ident: "1",
},
),
),
),
],
}

View file

@ -1,181 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-86,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-70 Apply(
@11-70 Var {
module_name: "Task",
ident: "await",
},
[
@11-70 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@11-70,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
spaces: [],
type_defs: [],
value_defs: [
AnnotatedBody {
ann_pattern: @11-70 Identifier {
ident: "#!0_stmt",
},
ann_type: @11-70 Apply(
"",
"Task",
[
@11-70 Record {
fields: [],
ext: None,
},
@11-70 Inferred,
],
),
lines_between: [],
body_pattern: @11-70 Identifier {
ident: "#!0_stmt",
},
body_expr: @11-70 Apply(
@11-70 Var {
module_name: "",
ident: "line",
},
[
@11-57 Apply(
@47-57 Var {
module_name: "Num",
ident: "to_str",
},
[
@11-39 Apply(
@24-39 When(
@24-32 Var {
module_name: "Str",
ident: "toU8",
},
[
WhenBranch {
patterns: [
@24-32 PncApply(
@24-32 Tag(
"Ok",
),
[
@24-32 Identifier {
ident: "success_BRANCH1_24_32",
},
],
),
],
value: @24-32 Var {
module_name: "",
ident: "success_BRANCH1_24_32",
},
guard: None,
},
WhenBranch {
patterns: [
@36-39 PncApply(
@24-32 Tag(
"Err",
),
[
@36-39 Underscore(
"",
),
],
),
],
value: @36-39 Num(
"255",
),
guard: None,
},
],
),
[
@11-16 Str(
PlainLine(
"123",
),
),
],
BinOp(
Pizza,
),
),
],
BinOp(
Pizza,
),
),
],
BinOp(
Pizza,
),
),
},
],
},
@11-70 Var {
module_name: "",
ident: "#!0_stmt",
},
),
@11-70 Closure(
[
@11-70 Underscore(
"#!stmt",
),
],
@76-86 Apply(
@76-83 Var {
module_name: "Task",
ident: "ok",
},
[
@84-86 Record(
[],
),
],
Space,
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,134 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-73,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@11-57 Apply(
@11-57 Var {
module_name: "Task",
ident: "await",
},
[
@11-57 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@11-57,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
body_pattern: @11-57 Identifier {
ident: "#!0_stmt",
},
body_expr: @11-57 Apply(
@11-57 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-57 Var {
module_name: "",
ident: "#!0_stmt",
},
),
@11-57 Closure(
[
@11-57 Underscore(
"#!stmt",
),
],
@63-73 Apply(
@63-70 Var {
module_name: "Task",
ident: "ok",
},
[
@71-73 Record(
[],
),
],
Space,
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,142 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-67,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "copy",
},
@7-67 Closure(
[
@8-9 Identifier {
ident: "a",
},
@10-11 Identifier {
ident: "b",
},
],
@19-30 Apply(
@19-30 Var {
module_name: "Task",
ident: "await",
},
[
@19-30 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@19-30,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
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: "#!1_stmt",
},
),
@19-30 Closure(
[
@19-30 Underscore(
"#!stmt",
),
],
@36-67 Apply(
@36-67 Var {
module_name: "",
ident: "mapErr",
},
[
@36-48 Apply(
@36-43 Var {
module_name: "CMD",
ident: "new",
},
[
@44-48 Str(
PlainLine(
"cp",
),
),
],
Space,
),
@64-67 Tag(
"ERR",
),
],
BinOp(
Pizza,
),
),
),
],
BangSuffix,
),
),
),
],
}

View file

@ -1,117 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-154,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@20-30 Apply(
@20-30 Var {
module_name: "Task",
ident: "await",
},
[
@20-30 Var {
module_name: "Stdin",
ident: "line",
},
@20-30 Closure(
[
@11-17 Identifier {
ident: "result",
},
],
@37-154 When(
@42-48 Var {
module_name: "",
ident: "result",
},
[
WhenBranch {
patterns: [
@60-63 Tag(
"End",
),
],
value: @79-89 Apply(
@79-86 Var {
module_name: "Task",
ident: "ok",
},
[
@87-89 Record(
[],
),
],
Space,
),
guard: None,
},
WhenBranch {
patterns: [
@99-109 Apply(
@99-104 Tag(
"Input",
),
[
@105-109 Identifier {
ident: "name",
},
],
),
],
value: @125-154 Apply(
@125-154 Var {
module_name: "Stdout",
ident: "line",
},
[
@138-154 Str(
Line(
[
Plaintext(
"Hello, ",
),
Interpolated(
@148-152 Var {
module_name: "",
ident: "name",
},
),
],
),
),
],
Space,
),
guard: None,
},
],
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,115 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-44,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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-29 Apply(
@28-29 Var {
module_name: "Task",
ident: "await",
},
[
@14-29 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@28-29,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
body_pattern: @24-25 Identifier {
ident: "#!0_expr",
},
body_expr: @28-29 Var {
module_name: "",
ident: "x",
},
},
],
},
@28-29 Var {
module_name: "",
ident: "#!0_expr",
},
),
@28-29 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,
),
),
),
],
}

View file

@ -1,107 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-45,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "main",
},
@15-18 Apply(
@15-18 Var {
module_name: "Task",
ident: "await",
},
[
@15-18 Var {
module_name: "",
ident: "foo",
},
@15-18 Closure(
[
@11-12 Identifier {
ident: "a",
},
],
@15-18 Apply(
@15-18 Var {
module_name: "Task",
ident: "await",
},
[
@28-33 Var {
module_name: "",
ident: "bar",
},
@15-18 Closure(
[
@28-33 Identifier {
ident: "#!0_arg",
},
],
@28-33 Apply(
@28-33 Var {
module_name: "Task",
ident: "await",
},
[
@28-33 Var {
module_name: "",
ident: "#!0_arg",
},
@28-33 Closure(
[
@24-25 Identifier {
ident: "b",
},
],
@38-45 Apply(
@38-41 Var {
module_name: "",
ident: "baz",
},
[
@42-43 Var {
module_name: "",
ident: "a",
},
@44-45 Var {
module_name: "",
ident: "b",
},
],
Space,
),
),
],
BangSuffix,
),
),
],
BangSuffix,
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,174 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-120,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "list",
},
@11-120 Apply(
@11-120 Var {
module_name: "Task",
ident: "await",
},
[
@16-23 Var {
module_name: "",
ident: "getList",
},
@11-120 Closure(
[
@16-23 Identifier {
ident: "#!2_arg",
},
],
@11-120 When(
@16-23 Var {
module_name: "",
ident: "#!2_arg",
},
[
WhenBranch {
patterns: [
@36-38 List(
[],
),
],
value: @54-65 Apply(
@54-65 Var {
module_name: "Task",
ident: "await",
},
[
@54-65 Defs(
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@54-65,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { 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,
],
),
lines_between: [],
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: "#!1_stmt",
},
),
@54-65 Closure(
[
@54-65 Underscore(
"#!stmt",
),
],
@78-89 Apply(
@78-89 Var {
module_name: "",
ident: "line",
},
[
@84-89 Str(
PlainLine(
"bar",
),
),
],
Space,
),
),
],
BangSuffix,
),
guard: None,
},
WhenBranch {
patterns: [
@98-99 Underscore(
"",
),
],
value: @115-120 Apply(
@115-117 Var {
module_name: "",
ident: "ok",
},
[
@118-120 Record(
[],
),
],
Space,
),
guard: None,
},
],
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,84 +0,0 @@
---
source: crates/compiler/can/tests/test_suffixed.rs
expression: snapshot
snapshot_kind: text
---
Defs {
tags: [
EitherIndex(2147483648),
],
regions: [
@0-74,
],
space_before: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
],
space_after: [
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
],
spaces: [
Newline,
],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier {
ident: "list",
},
@11-74 Apply(
@11-74 Var {
module_name: "Task",
ident: "await",
},
[
@16-23 Var {
module_name: "",
ident: "getList",
},
@11-74 Closure(
[
@16-23 Identifier {
ident: "#!0_arg",
},
],
@11-74 When(
@16-23 Var {
module_name: "",
ident: "#!0_arg",
},
[
WhenBranch {
patterns: [
@36-38 List(
[],
),
],
value: @42-49 Str(
PlainLine(
"empty",
),
),
guard: None,
},
WhenBranch {
patterns: [
@58-59 Underscore(
"",
),
],
value: @63-74 Str(
PlainLine(
"non-empty",
),
),
guard: None,
},
],
),
),
],
BangSuffix,
),
),
],
}

View file

@ -1,690 +0,0 @@
#[macro_use]
extern crate indoc;
#[cfg(test)]
mod suffixed_tests {
use bumpalo::Bump;
use insta::assert_snapshot;
use roc_can::desugar::desugar_defs_node_values;
use roc_can::env::{Env, FxMode};
use roc_can::scope::Scope;
use roc_module::symbol::{IdentIds, ModuleIds, PackageModuleIds};
use roc_parse::test_helpers::parse_defs_with;
use std::path::Path;
macro_rules! run_test {
($src:expr) => {{
let arena = &Bump::new();
let home = ModuleIds::default().get_or_insert(&"Test".into());
let mut scope = Scope::new(
home,
"TestPath".into(),
IdentIds::default(),
Default::default(),
);
let dep_idents = IdentIds::exposed_builtins(0);
let qualified_module_ids = PackageModuleIds::default();
let mut env = Env::new(
arena,
$src,
home,
Path::new("test.roc"),
&dep_idents,
&qualified_module_ids,
None,
FxMode::Task,
);
let mut defs = parse_defs_with(arena, indoc!($src)).unwrap();
desugar_defs_node_values(&mut env, &mut scope, &mut defs, true);
let snapshot = format!("{:#?}", &defs);
println!("{}", snapshot);
assert_snapshot!(snapshot);
}};
}
/**
* This example tests a suffixed statement, followed
* by a Body with an empty record pattern.
*
* The def final expression is explicitly provided.
*/
#[test]
fn multi_defs_stmts() {
run_test!(
r#"
main =
line! "Ahoy"
{} = "There" |> Stdout.line!
Task.ok {}
"#
);
}
/**
* The most simple suffixed example. A single statement
* without arguments and a final expression.
*/
#[test]
fn basic() {
run_test!(
r#"
main =
foo!
ok {}
"#
);
}
/**
* A single suffixed statement with arguments applied.
* Note there is no final expression.
*/
#[test]
fn last_suffixed_single() {
run_test!(
r#"
main = foo! "bar" {} "baz"
"#
);
}
/**
* Multiple suffixed statements with no
* arguments, and no final expression.
*/
#[test]
fn last_suffixed_multiple() {
run_test!(
r#"
main =
foo!
bar!
baz!
"#
);
}
/**
* A definition with a closure that contains a Defs node, which also
* contains a suffixed binops statement.
*/
#[test]
fn closure_simple() {
run_test!(
r#"
main =
x = \msg ->
msg |> line!
ok {}
x "hi"
"#
);
}
/**
* Example of unwrapping a pipline statement
*
* Note pipelines are desugared into Apply functions,
* however this also tests the parser.
*
*/
#[test]
fn simple_pizza() {
run_test!(
r#"
main =
"hello"
|> Str.concat "world"
|> line!
Task.ok {}
"#
);
}
/**
* Example of unwrapping a Result with ?? operator
*
* Note that ?? is desugared into a when expression,
* however this also tests the parser.
*
*/
#[test]
fn simple_double_question() {
run_test!(
r#"
main =
"123"
|> Str.toU8 ?? 255
|> Num.to_str
|> line!
Task.ok {}
"#
);
}
/**
* Example with a parens suffixed sub-expression
* in the function part of an Apply.
*
* Note how the parens unwraps into an intermediate answer #!0_arg instead of
* unwrapping the def `do`.
*
*/
#[test]
fn body_parens_apply() {
run_test!(
r#"
main =
do = (sayMultiple!) "hi"
do
"#
);
}
/**
* Example of unwrapping mixed Body defs with
* Var's of both single and multiple suffixes
*/
#[test]
fn var_suffixes() {
run_test!(
r#"
main =
a = foo!
b = bar!!
baz a b
"#
);
}
/**
* Example with a multiple suffixed Var
*
* Note it unwraps into an intermediate answer `#!0_arg`
*
*/
#[test]
fn multiple_suffix() {
run_test!(
r#"
main =
foo!!
bar
"#
);
}
/**
* A suffixed expression in the function part of the Apply
*/
#[test]
fn apply_function_suffixed() {
run_test!(
r#"
main =
x = (foo! "bar") "hello"
baz x
"#
);
}
/**
* A suffixed expression in an Apply argument position.
*/
#[test]
fn apply_argument_suffixed() {
run_test!(
r#"
main =
x = bar (foo! "hello")
baz x
"#
);
}
/**
* Example where the suffixed def is not the first def
*/
#[test]
fn multiple_def_first_suffixed() {
run_test!(
r#"
main =
msg = "hello"
x = foo! msg
bar x
"#
);
}
/**
* Annotated defs and a suffixed expression
* with annotations inside a closure
*/
#[test]
fn closure_with_annotations() {
run_test!(
r#"
main =
x : Str -> Task _ _
x = \msg ->
y : Task {} _
y = line! msg
y
x "foo"
"#
);
}
/**
* Nested suffixed expressions
*/
#[test]
fn nested_simple() {
run_test!(
r#"
run = line! (nextMsg!)
"#
);
}
/**
* Nested suffixed expressions
*/
#[test]
fn nested_complex() {
run_test!(
r#"
main =
z = foo! (bar! baz) (blah stuff)
doSomething z
"#
);
}
/**
* A closure that contains a Defs node
*/
#[test]
fn closure_with_defs() {
run_test!(
r#"
main =
foo : Str, {}, Str -> Task {} I32
foo = \a, _, b ->
line! a
line! b
Task.ok {}
foo "bar" {} "baz"
"#
);
}
/**
* Test when the suffixed def being unwrapped is not the first or last
*/
#[test]
fn defs_suffixed_middle() {
run_test!(
r#"
main =
a = "Foo"
Stdout.line! a
printBar!
printBar =
b = "Bar"
Stdout.line b
"#
);
}
/**
* A simple if-then-else statement which is split
*/
#[test]
fn if_simple() {
run_test!(
r#"
main =
isTrue = Task.ok Bool.true
isFalse = Task.ok Bool.false
if isFalse! then
line "fail"
else if isTrue! then
line "success"
else
line "fail"
"#
);
}
/**
* A more complex example including the use of nested Defs nodes
*/
#[test]
fn if_complex() {
run_test!(
r#"
main =
isTrue = Task.ok Bool.true
isFalsey = \x -> Task.ok x
msg : Task {} I32
msg =
if !(isTrue!) then
line! "fail"
err 1
else if (isFalsey! Bool.false) then
line! "nope"
ok {}
else
line! "success"
msg
"#
);
}
/**
* Unwrap a trailing binops
*/
#[test]
fn trailing_binops() {
run_test!(
r#"
copy = \a,b ->
line! "FOO"
CMD.new "cp"
|> mapErr! ERR
"#
);
}
/**
* Unwrap a when expression
*/
#[test]
fn when_simple() {
run_test!(
r#"
list =
when getList! is
[] -> "empty"
_ -> "non-empty"
"#
);
}
/**
* Unwrap a when expression
*/
#[test]
fn when_branches() {
run_test!(
r#"
list =
when getList! is
[] ->
line! "foo"
line! "bar"
_ ->
ok {}
"#
);
}
#[test]
fn trailing_suffix_inside_when() {
run_test!(
r#"
main =
result = Stdin.line!
when result is
End ->
Task.ok {}
Input name ->
Stdout.line! "Hello, $(name)"
"#
);
}
#[test]
fn dbg_simple() {
run_test!(
r#"
main =
foo = getFoo!
dbg foo
bar! foo
"#
);
}
#[test]
fn dbg_expr() {
run_test!(
r#"
main =
dbg (dbg (1 + 1))
"#
);
}
#[test]
fn pizza_dbg() {
run_test!(
r#"
main =
1
|> dbg
|> Num.add 2
|> dbg
"#
)
}
#[test]
fn apply_argument_single() {
run_test!(
r#"
main =
c = b a!
c
"#
);
}
#[test]
fn apply_argument_multiple() {
run_test!(
r#"
main =
c = b a! x!
c
"#
);
}
#[test]
fn bang_in_pipe_root() {
run_test!(
r#"
main =
c = a! |> b
c
"#
);
}
#[test]
fn expect_then_bang() {
run_test!(
r#"
main =
expect 1 == 2
x!
"#
);
}
#[test]
fn deep_when() {
run_test!(
r#"
main =
when a is
0 ->
when b is
1 ->
c!
"#
);
}
#[test]
fn deps_final_expr() {
run_test!(
r#"
main =
when x is
A ->
y = 42
if a then
b!
else
c!
B ->
d!
"#
);
}
#[test]
fn dbg_stmt_arg() {
run_test!(
r#"
main =
dbg a!
b
"#
)
}
#[test]
fn last_stmt_not_top_level_suffixed() {
run_test!(
r#"
main =
x = 42
a b!
"#
);
}
#[test]
fn nested_defs() {
run_test!(
r##"
main =
x =
a = b!
c! a
x
"##
);
}
#[test]
fn type_annotation() {
run_test!(
r##"
f = \x ->
r : A
r = x!
Task.ok r
"##
);
}
#[test]
fn issue_7081() {
run_test!(
r##"
inc = \i ->
if i > 2 then
Err MaxReached
else
Ok (i + 1)
expect
run = \i ->
newi =
i
|> inc?
|> inc?
Ok newi
result = run 0
result == Ok 2
main =
Stdout.line! "Hello world"
"##
);
}
#[test]
fn issue_7103() {
run_test!(
r##"
run : Task {} _
run = line! "foo"
main = run
"##
);
}
}
#[cfg(test)]
mod test_suffixed_helpers {
use roc_can::suffixed::is_matching_intermediate_answer;
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: "#!0_arg" });
let loc_new = Loc::at_zero(Expr::Var {
module_name: "",
ident: "#!0_arg",
});
std::assert!(is_matching_intermediate_answer(&loc_pat, &loc_new));
}
}