add suffixed to Identifer and QualifiedIdentifier

This commit is contained in:
Luke Boswell 2024-03-26 14:17:48 +11:00
parent 0a3b9c34b3
commit 3c3e523b45
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
115 changed files with 1587 additions and 1085 deletions

View file

@ -748,9 +748,10 @@ fn can_annotation_help(
for loc_var in *loc_vars { for loc_var in *loc_vars {
let var = match loc_var.value { let var = match loc_var.value {
Pattern::Identifier(name) if name.chars().next().unwrap().is_lowercase() => { Pattern::Identifier {
name ident: name,
} suffixed: _,
} if name.chars().next().unwrap().is_lowercase() => name,
_ => unreachable!("I thought this was validated during parsing"), _ => unreachable!("I thought this was validated during parsing"),
}; };
let var_name = Lowercase::from(var); let var_name = Lowercase::from(var);

View file

@ -547,7 +547,11 @@ fn canonicalize_claimed_ability_impl<'a>(
} }
AssignedField::RequiredValue(label, _spaces, value) => { AssignedField::RequiredValue(label, _spaces, value) => {
let impl_ident = match value.value { let impl_ident = match value.value {
ast::Expr::Var { module_name, ident } => { ast::Expr::Var {
module_name,
ident,
suffixed: _,
} => {
if module_name.is_empty() { if module_name.is_empty() {
ident ident
} else { } else {
@ -2570,9 +2574,10 @@ fn to_pending_alias_or_opaque<'a>(
for loc_var in vars.iter() { for loc_var in vars.iter() {
match loc_var.value { match loc_var.value {
ast::Pattern::Identifier(name) ast::Pattern::Identifier {
if name.chars().next().unwrap().is_lowercase() => ident: name,
{ suffixed: _,
} if name.chars().next().unwrap().is_lowercase() => {
let lowercase = Lowercase::from(name); let lowercase = Lowercase::from(name);
can_rigids.push(Loc { can_rigids.push(Loc {
value: lowercase, value: lowercase,
@ -2874,6 +2879,8 @@ fn to_pending_value_def<'a>(
condition, condition,
preceding_comment: *preceding_comment, preceding_comment: *preceding_comment,
}), }),
Stmt(_) => todo!(),
} }
} }

View file

@ -23,9 +23,13 @@ fn to_encoder<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
let opaque_ref = alloc_pat(ast::Pattern::OpaqueRef(at_opaque)); let opaque_ref = alloc_pat(ast::Pattern::OpaqueRef(at_opaque));
let opaque_apply_pattern = ast::Pattern::Apply( let opaque_apply_pattern = ast::Pattern::Apply(
opaque_ref, opaque_ref,
&*env &*env.arena.alloc([Loc::at(
.arena DERIVED_REGION,
.alloc([Loc::at(DERIVED_REGION, ast::Pattern::Identifier(payload))]), ast::Pattern::Identifier {
ident: payload,
suffixed: 0,
},
)]),
); );
// Encode.toEncoder payload // Encode.toEncoder payload
@ -33,10 +37,12 @@ fn to_encoder<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
alloc_expr(ast::Expr::Var { alloc_expr(ast::Expr::Var {
module_name: "Encode", module_name: "Encode",
ident: "toEncoder", ident: "toEncoder",
suffixed: 0,
}), }),
&*env.arena.alloc([&*alloc_expr(ast::Expr::Var { &*env.arena.alloc([&*alloc_expr(ast::Expr::Var {
module_name: "", module_name: "",
ident: payload, ident: payload,
suffixed: 0,
})]), })]),
roc_module::called_via::CalledVia::Space, roc_module::called_via::CalledVia::Space,
)); ));
@ -61,19 +67,23 @@ fn decoder<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
alloc_expr(ast::Expr::Var { alloc_expr(ast::Expr::Var {
module_name: "Decode", module_name: "Decode",
ident: "decodeWith", ident: "decodeWith",
suffixed: 0,
}), }),
env.arena.alloc([ env.arena.alloc([
&*alloc_expr(ast::Expr::Var { &*alloc_expr(ast::Expr::Var {
module_name: "", module_name: "",
ident: bytes, ident: bytes,
suffixed: 0,
}), }),
alloc_expr(ast::Expr::Var { alloc_expr(ast::Expr::Var {
module_name: "Decode", module_name: "Decode",
ident: "decoder", ident: "decoder",
suffixed: 0,
}), }),
alloc_expr(ast::Expr::Var { alloc_expr(ast::Expr::Var {
module_name: "", module_name: "",
ident: fmt, ident: fmt,
suffixed: 0,
}), }),
]), ]),
CalledVia::Space, CalledVia::Space,
@ -84,6 +94,7 @@ fn decoder<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
alloc_expr(ast::Expr::Var { alloc_expr(ast::Expr::Var {
module_name: "Decode", module_name: "Decode",
ident: "mapResult", ident: "mapResult",
suffixed: 0,
}), }),
env.arena.alloc([ env.arena.alloc([
&*alloc_expr(call_decode_with), &*alloc_expr(call_decode_with),
@ -96,8 +107,20 @@ fn decoder<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
// Decode.mapResult (Decode.decodeWith bytes Decode.decoder fmt) @Opaq // Decode.mapResult (Decode.decodeWith bytes Decode.decoder fmt) @Opaq
let custom_closure = ast::Expr::Closure( let custom_closure = ast::Expr::Closure(
env.arena.alloc([ env.arena.alloc([
Loc::at(DERIVED_REGION, ast::Pattern::Identifier(bytes)), Loc::at(
Loc::at(DERIVED_REGION, ast::Pattern::Identifier(fmt)), DERIVED_REGION,
ast::Pattern::Identifier {
ident: bytes,
suffixed: 0,
},
),
Loc::at(
DERIVED_REGION,
ast::Pattern::Identifier {
ident: fmt,
suffixed: 0,
},
),
]), ]),
alloc_expr(call_map_result), alloc_expr(call_map_result),
); );
@ -107,6 +130,7 @@ fn decoder<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
alloc_expr(ast::Expr::Var { alloc_expr(ast::Expr::Var {
module_name: "Decode", module_name: "Decode",
ident: "custom", ident: "custom",
suffixed: 0,
}), }),
env.arena.alloc([&*alloc_expr(custom_closure)]), env.arena.alloc([&*alloc_expr(custom_closure)]),
CalledVia::Space, CalledVia::Space,
@ -127,9 +151,13 @@ fn hash<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
let opaque_ref = alloc_pat(ast::Pattern::OpaqueRef(at_opaque)); let opaque_ref = alloc_pat(ast::Pattern::OpaqueRef(at_opaque));
let opaque_apply_pattern = ast::Pattern::Apply( let opaque_apply_pattern = ast::Pattern::Apply(
opaque_ref, opaque_ref,
&*env &*env.arena.alloc([Loc::at(
.arena DERIVED_REGION,
.alloc([Loc::at(DERIVED_REGION, ast::Pattern::Identifier(payload))]), ast::Pattern::Identifier {
ident: payload,
suffixed: 0,
},
)]),
); );
// Hash.hash hasher payload // Hash.hash hasher payload
@ -137,15 +165,18 @@ fn hash<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
alloc_expr(ast::Expr::Var { alloc_expr(ast::Expr::Var {
module_name: "Hash", module_name: "Hash",
ident: "hash", ident: "hash",
suffixed: 0,
}), }),
&*env.arena.alloc([ &*env.arena.alloc([
&*alloc_expr(ast::Expr::Var { &*alloc_expr(ast::Expr::Var {
module_name: "", module_name: "",
ident: hasher, ident: hasher,
suffixed: 0,
}), }),
&*alloc_expr(ast::Expr::Var { &*alloc_expr(ast::Expr::Var {
module_name: "", module_name: "",
ident: payload, ident: payload,
suffixed: 0,
}), }),
]), ]),
roc_module::called_via::CalledVia::Space, roc_module::called_via::CalledVia::Space,
@ -154,7 +185,13 @@ fn hash<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
// \hasher, @Opaq payload -> Hash.hash hasher payload // \hasher, @Opaq payload -> Hash.hash hasher payload
ast::Expr::Closure( ast::Expr::Closure(
env.arena.alloc([ env.arena.alloc([
Loc::at(DERIVED_REGION, ast::Pattern::Identifier(hasher)), Loc::at(
DERIVED_REGION,
ast::Pattern::Identifier {
ident: hasher,
suffixed: 0,
},
),
Loc::at(DERIVED_REGION, opaque_apply_pattern), Loc::at(DERIVED_REGION, opaque_apply_pattern),
]), ]),
call_member, call_member,
@ -172,16 +209,24 @@ fn is_eq<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
// \@Opaq payload1 // \@Opaq payload1
let opaque1 = ast::Pattern::Apply( let opaque1 = ast::Pattern::Apply(
opaque_ref, opaque_ref,
&*env &*env.arena.alloc([Loc::at(
.arena DERIVED_REGION,
.alloc([Loc::at(DERIVED_REGION, ast::Pattern::Identifier(payload1))]), ast::Pattern::Identifier {
ident: payload1,
suffixed: 0,
},
)]),
); );
// \@Opaq payload2 // \@Opaq payload2
let opaque2 = ast::Pattern::Apply( let opaque2 = ast::Pattern::Apply(
opaque_ref, opaque_ref,
&*env &*env.arena.alloc([Loc::at(
.arena DERIVED_REGION,
.alloc([Loc::at(DERIVED_REGION, ast::Pattern::Identifier(payload2))]), ast::Pattern::Identifier {
ident: payload2,
suffixed: 0,
},
)]),
); );
// Bool.isEq payload1 payload2 // Bool.isEq payload1 payload2
@ -189,15 +234,18 @@ fn is_eq<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
alloc_expr(ast::Expr::Var { alloc_expr(ast::Expr::Var {
module_name: "Bool", module_name: "Bool",
ident: "isEq", ident: "isEq",
suffixed: 0,
}), }),
&*env.arena.alloc([ &*env.arena.alloc([
&*alloc_expr(ast::Expr::Var { &*alloc_expr(ast::Expr::Var {
module_name: "", module_name: "",
ident: payload1, ident: payload1,
suffixed: 0,
}), }),
&*alloc_expr(ast::Expr::Var { &*alloc_expr(ast::Expr::Var {
module_name: "", module_name: "",
ident: payload2, ident: payload2,
suffixed: 0,
}), }),
]), ]),
roc_module::called_via::CalledVia::Space, roc_module::called_via::CalledVia::Space,
@ -224,9 +272,13 @@ fn to_inspector<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
let opaque_ref = alloc_pat(ast::Pattern::OpaqueRef(at_opaque)); let opaque_ref = alloc_pat(ast::Pattern::OpaqueRef(at_opaque));
let opaque_apply_pattern = ast::Pattern::Apply( let opaque_apply_pattern = ast::Pattern::Apply(
opaque_ref, opaque_ref,
&*env &*env.arena.alloc([Loc::at(
.arena DERIVED_REGION,
.alloc([Loc::at(DERIVED_REGION, ast::Pattern::Identifier(payload))]), ast::Pattern::Identifier {
ident: payload,
suffixed: 0,
},
)]),
); );
// Inspect.toInspector payload // Inspect.toInspector payload
@ -234,10 +286,12 @@ fn to_inspector<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
alloc_expr(ast::Expr::Var { alloc_expr(ast::Expr::Var {
module_name: "Inspect", module_name: "Inspect",
ident: "toInspector", ident: "toInspector",
suffixed: 0,
}), }),
&*env.arena.alloc([&*alloc_expr(ast::Expr::Var { &*env.arena.alloc([&*alloc_expr(ast::Expr::Var {
module_name: "", module_name: "",
ident: payload, ident: payload,
suffixed: 0,
})]), })]),
roc_module::called_via::CalledVia::Space, roc_module::called_via::CalledVia::Space,
)); ));
@ -252,6 +306,7 @@ fn to_inspector<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
alloc_expr(ast::Expr::Var { alloc_expr(ast::Expr::Var {
module_name: "Inspect", module_name: "Inspect",
ident: "tag", ident: "tag",
suffixed: 0,
}), }),
&*env.arena.alloc([&*opaque_name, &*to_inspector_list]), &*env.arena.alloc([&*opaque_name, &*to_inspector_list]),
roc_module::called_via::CalledVia::Space, roc_module::called_via::CalledVia::Space,
@ -264,20 +319,27 @@ fn to_inspector<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
alloc_expr(ast::Expr::Var { alloc_expr(ast::Expr::Var {
module_name: "Inspect", module_name: "Inspect",
ident: "apply", ident: "apply",
suffixed: 0,
}), }),
&*env.arena.alloc([ &*env.arena.alloc([
&*opaque_inspector, &*opaque_inspector,
&*alloc_expr(ast::Expr::Var { &*alloc_expr(ast::Expr::Var {
module_name: "", module_name: "",
ident: fmt, ident: fmt,
suffixed: 0,
}), }),
]), ]),
roc_module::called_via::CalledVia::Space, roc_module::called_via::CalledVia::Space,
)); ));
let custom_closure = alloc_expr(ast::Expr::Closure( let custom_closure = alloc_expr(ast::Expr::Closure(
env.arena env.arena.alloc([Loc::at(
.alloc([Loc::at(DERIVED_REGION, ast::Pattern::Identifier(fmt))]), DERIVED_REGION,
ast::Pattern::Identifier {
ident: fmt,
suffixed: 0,
},
)]),
apply_opaque_inspector, apply_opaque_inspector,
)); ));
@ -286,6 +348,7 @@ fn to_inspector<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
alloc_expr(ast::Expr::Var { alloc_expr(ast::Expr::Var {
module_name: "Inspect", module_name: "Inspect",
ident: "custom", ident: "custom",
suffixed: 0,
}), }),
env.arena.alloc([&*custom_closure]), env.arena.alloc([&*custom_closure]),
CalledVia::Space, CalledVia::Space,

View file

@ -56,7 +56,11 @@ fn new_op_call_expr<'a>(
let args = arena.alloc([left, right]); let args = arena.alloc([left, right]);
let loc_expr = arena.alloc(Loc { let loc_expr = arena.alloc(Loc {
value: Expr::Var { module_name, ident }, value: Expr::Var {
module_name,
ident,
suffixed: 0,
},
region: loc_op.region, region: loc_op.region,
}); });
@ -128,6 +132,8 @@ fn desugar_value_def<'a>(
preceding_comment: *preceding_comment, preceding_comment: *preceding_comment,
} }
} }
Stmt(_) => todo!(),
} }
} }
@ -188,6 +194,7 @@ fn desugar_defs_node_suffixed<'a>(
value: Var { value: Var {
module_name: ModuleName::TASK, module_name: ModuleName::TASK,
ident: "await", ident: "await",
suffixed: 0, // TODO this isn't right
}, },
}), }),
arena.alloc(task_await_apply_args), arena.alloc(task_await_apply_args),
@ -246,6 +253,7 @@ fn desugar_defs_node_suffixed<'a>(
value: Var { value: Var {
module_name: ModuleName::TASK, module_name: ModuleName::TASK,
ident: "await", ident: "await",
suffixed: 0, // TODO this isn't right
}, },
}), }),
arena.alloc(task_await_apply_args), arena.alloc(task_await_apply_args),
@ -307,6 +315,7 @@ fn desugar_defs_node_suffixed<'a>(
value: Var { value: Var {
module_name: ModuleName::TASK, module_name: ModuleName::TASK,
ident: "await", ident: "await",
suffixed: 0, // TODO this isn't right
}, },
}), }),
arena.alloc(task_await_apply_args), arena.alloc(task_await_apply_args),
@ -337,28 +346,29 @@ fn unwrap_suffixed_def_and_pattern<'a>(
roc_parse::ast::Expr<'a>, roc_parse::ast::Expr<'a>,
&'a Loc<roc_parse::ast::Pattern<'a>>, &'a Loc<roc_parse::ast::Pattern<'a>>,
) { ) {
match value_def { todo!()
ValueDef::Body(pattern, suffixed_expression) => match suffixed_expression.value { // match value_def {
// The Suffixed has arguments applied e.g. `Stdout.line! "Hello World"` // ValueDef::Body(pattern, suffixed_expression) => match suffixed_expression.value {
Apply(sub_loc, suffixed_args, called_via) => match sub_loc.value { // // The Suffixed has arguments applied e.g. `Stdout.line! "Hello World"`
Suffixed(sub_expr) => ( // Apply(sub_loc, suffixed_args, called_via) => match sub_loc.value {
Apply( // Suffixed(sub_expr) => (
arena.alloc(Loc::at(region, *sub_expr)), // Apply(
suffixed_args, // arena.alloc(Loc::at(region, *sub_expr)),
called_via, // suffixed_args,
), // called_via,
pattern, // ),
), // pattern,
_ => unreachable!("should have a suffixed Apply inside Body def"), // ),
}, // _ => unreachable!("should have a suffixed Apply inside Body def"),
// The Suffixed has NIL arguments applied e.g. `Stdin.line!` // },
Suffixed(sub_expr) => (*sub_expr, pattern), // // The Suffixed has NIL arguments applied e.g. `Stdin.line!`
_ => { // Suffixed(sub_expr) => (*sub_expr, pattern),
unreachable!("should have a suffixed Apply inside Body def") // _ => {
} // unreachable!("should have a suffixed Apply inside Body def")
}, // }
_ => unreachable!("should have a suffixed Body def"), // },
} // _ => unreachable!("should have a suffixed Body def"),
// }
} }
/// Reorder the expression tree based on operator precedence and associativity rules, /// Reorder the expression tree based on operator precedence and associativity rules,
@ -699,10 +709,12 @@ pub fn desugar_expr<'a>(
Negate => Var { Negate => Var {
module_name: ModuleName::NUM, module_name: ModuleName::NUM,
ident: "neg", ident: "neg",
suffixed: 0,
}, },
Not => Var { Not => Var {
module_name: ModuleName::BOOL, module_name: ModuleName::BOOL,
ident: "not", ident: "not",
suffixed: 0,
}, },
}; };
let loc_fn_var = arena.alloc(Loc { region, value }); let loc_fn_var = arena.alloc(Loc { region, value });
@ -800,6 +812,7 @@ pub fn desugar_expr<'a>(
let inspect_fn = Var { let inspect_fn = Var {
module_name: ModuleName::INSPECT, module_name: ModuleName::INSPECT,
ident: "toStr", ident: "toStr",
suffixed: 0,
}; };
let loc_inspect_fn_var = arena.alloc(Loc { let loc_inspect_fn_var = arena.alloc(Loc {
value: inspect_fn, value: inspect_fn,
@ -840,30 +853,30 @@ pub fn desugar_expr<'a>(
}) })
} }
LowLevelDbg(_, _, _) => unreachable!("Only exists after desugaring"), LowLevelDbg(_, _, _) => unreachable!("Only exists after desugaring"),
Suffixed(expr) => { // Suffixed(expr) => {
// Rewrite `Suffixed(BinOps([args...], Var(...)))` to `BinOps([args...], Suffixed(Var(...)))` // // Rewrite `Suffixed(BinOps([args...], Var(...)))` to `BinOps([args...], Suffixed(Var(...)))`
// This is to handle cases like e.g. `"Hello" |> line!` // // This is to handle cases like e.g. `"Hello" |> line!`
if let BinOps(args, sub_expr) = expr { // if let BinOps(args, sub_expr) = expr {
return desugar_expr( // return desugar_expr(
arena, // arena,
arena.alloc(Loc::at( // arena.alloc(Loc::at(
loc_expr.region, // loc_expr.region,
BinOps( // BinOps(
args, // args,
arena.alloc(Loc::at(sub_expr.region, Suffixed(&sub_expr.value))), // arena.alloc(Loc::at(sub_expr.region, Suffixed(&sub_expr.value))),
), // ),
)), // )),
src, // src,
line_info, // line_info,
module_path, // module_path,
); // );
} // }
// Suffixed are also desugared in Defs // // Suffixed are also desugared in Defs
// Any nodes that don't get desugared will be caught by canonicalize_expr // // Any nodes that don't get desugared will be caught by canonicalize_expr
// and we can handle those cases as required // // and we can handle those cases as required
loc_expr // loc_expr
} // }
} }
} }
@ -949,6 +962,7 @@ fn desugar_field<'a>(
value: Var { value: Var {
module_name: "", module_name: "",
ident: loc_str.value, ident: loc_str.value,
suffixed: 0,
}, },
region: loc_str.region, region: loc_str.region,
}; };
@ -1009,7 +1023,7 @@ fn desugar_pattern<'a>(
use roc_parse::ast::Pattern::*; use roc_parse::ast::Pattern::*;
match pattern { match pattern {
Identifier(_) Identifier { .. }
| Tag(_) | Tag(_)
| OpaqueRef(_) | OpaqueRef(_)
| NumLiteral(_) | NumLiteral(_)
@ -1093,8 +1107,6 @@ fn desugar_pattern<'a>(
SpaceAfter(sub_pattern, _spaces) => { SpaceAfter(sub_pattern, _spaces) => {
desugar_pattern(arena, *sub_pattern, src, line_info, module_path) desugar_pattern(arena, *sub_pattern, src, line_info, module_path)
} }
Stmt(_) => unreachable!("should have been handled in the parser"),
} }
} }
@ -1131,6 +1143,7 @@ fn record_builder_arg<'a>(
value: Expr::Var { value: Expr::Var {
module_name: "", module_name: "",
ident: arena.alloc("#".to_owned() + label.value), ident: arena.alloc("#".to_owned() + label.value),
suffixed: 0,
}, },
}); });
@ -1170,7 +1183,10 @@ fn record_builder_arg<'a>(
for label in apply_field_names.iter().rev() { for label in apply_field_names.iter().rev() {
let name = arena.alloc("#".to_owned() + label.value); let name = arena.alloc("#".to_owned() + label.value);
let ident = roc_parse::ast::Pattern::Identifier(name); let ident = roc_parse::ast::Pattern::Identifier {
ident: name,
suffixed: 0,
};
let arg_pattern = arena.alloc(Loc { let arg_pattern = arena.alloc(Loc {
value: ident, value: ident,

View file

@ -1016,9 +1016,11 @@ pub fn canonicalize_expr<'a>(
(expr, output) (expr, output)
} }
} }
ast::Expr::Var { module_name, ident } => { ast::Expr::Var {
canonicalize_var_lookup(env, var_store, scope, module_name, ident, region) module_name,
} ident,
suffixed: _, // TODO should we use suffixed here?
} => canonicalize_var_lookup(env, var_store, scope, module_name, ident, region),
ast::Expr::Underscore(name) => { ast::Expr::Underscore(name) => {
// we parse underscores, but they are not valid expression syntax // we parse underscores, but they are not valid expression syntax
@ -1441,12 +1443,6 @@ pub fn canonicalize_expr<'a>(
bad_expr bad_expr
); );
} }
bad_expr @ ast::Expr::Suffixed(_) => {
internal_error!(
"A suffixed expression did not get desugared somehow: {:#?}",
bad_expr
);
}
}; };
// At the end, diff used_idents and defined_idents to see which were unused. // At the end, diff used_idents and defined_idents to see which were unused.
@ -2512,7 +2508,6 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
ast::RecordBuilderField::SpaceBefore(_, _) ast::RecordBuilderField::SpaceBefore(_, _)
| ast::RecordBuilderField::SpaceAfter(_, _) => false, | ast::RecordBuilderField::SpaceAfter(_, _) => false,
}), }),
ast::Expr::Suffixed(_) => todo!(),
} }
} }

View file

@ -6,7 +6,6 @@ use crate::num::{
ParsedNumResult, ParsedNumResult,
}; };
use crate::scope::{PendingAbilitiesInScope, Scope}; use crate::scope::{PendingAbilitiesInScope, Scope};
use roc_error_macros::internal_error;
use roc_exhaustive::ListArity; use roc_exhaustive::ListArity;
use roc_module::ident::{Ident, Lowercase, TagName}; use roc_module::ident::{Ident, Lowercase, TagName};
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
@ -266,7 +265,11 @@ pub fn canonicalize_def_header_pattern<'a>(
match pattern { match pattern {
// Identifiers that shadow ability members may appear (and may only appear) at the header of a def. // Identifiers that shadow ability members may appear (and may only appear) at the header of a def.
Identifier(name) => { // TODO should we use suffixed here?
Identifier {
ident: name,
suffixed: _,
} => {
match scope.introduce_or_shadow_ability_member( match scope.introduce_or_shadow_ability_member(
pending_abilities_in_scope, pending_abilities_in_scope,
(*name).into(), (*name).into(),
@ -374,12 +377,14 @@ pub fn canonicalize_pattern<'a>(
use PatternType::*; use PatternType::*;
let can_pattern = match pattern { let can_pattern = match pattern {
Identifier(name) => { // TODO do we need to use suffixed here?
match canonicalize_pattern_symbol(env, scope, output, region, permit_shadows, name) { Identifier {
ident: name,
suffixed: _,
} => match canonicalize_pattern_symbol(env, scope, output, region, permit_shadows, name) {
Ok(symbol) => Pattern::Identifier(symbol), Ok(symbol) => Pattern::Identifier(symbol),
Err(pattern) => pattern, Err(pattern) => pattern,
} },
}
Underscore(name) => { Underscore(name) => {
// An underscored identifier can't be used, but we'll still add it to the scope // An underscored identifier can't be used, but we'll still add it to the scope
// for better error messages if someone tries to use it. // for better error messages if someone tries to use it.
@ -629,7 +634,11 @@ pub fn canonicalize_pattern<'a>(
for loc_pattern in patterns.iter() { for loc_pattern in patterns.iter() {
match loc_pattern.value { match loc_pattern.value {
Identifier(label) => { // TODO should we use suffixed here?
Identifier {
ident: label,
suffixed: _,
} => {
match scope.introduce(label.into(), region) { match scope.introduce(label.into(), region) {
Ok(symbol) => { Ok(symbol) => {
output.references.insert_bound(symbol); output.references.insert_bound(symbol);
@ -883,8 +892,6 @@ pub fn canonicalize_pattern<'a>(
let problem = MalformedPatternProblem::QualifiedIdentifier; let problem = MalformedPatternProblem::QualifiedIdentifier;
malformed_pattern(env, problem, region) malformed_pattern(env, problem, region)
} }
Stmt(_) => internal_error!("should have been handled in the parser"),
}; };
Loc { Loc {

View file

@ -196,10 +196,11 @@ impl<'a> Formattable for ValueDef<'a> {
Expect { condition, .. } => condition.is_multiline(), Expect { condition, .. } => condition.is_multiline(),
ExpectFx { condition, .. } => condition.is_multiline(), ExpectFx { condition, .. } => condition.is_multiline(),
Dbg { condition, .. } => condition.is_multiline(), Dbg { condition, .. } => condition.is_multiline(),
Stmt(loc_expr) => loc_expr.is_multiline(),
} }
} }
fn format_with_options(&self, buf: &mut Buf, _parens: Parens, newlines: Newlines, indent: u16) { fn format_with_options(&self, buf: &mut Buf, parens: Parens, newlines: Newlines, indent: u16) {
use roc_parse::ast::ValueDef::*; use roc_parse::ast::ValueDef::*;
match self { match self {
Annotation(loc_pattern, loc_annotation) => { Annotation(loc_pattern, loc_annotation) => {
@ -238,6 +239,7 @@ impl<'a> Formattable for ValueDef<'a> {
buf.newline(); buf.newline();
fmt_body(buf, &body_pattern.value, &body_expr.value, indent); fmt_body(buf, &body_pattern.value, &body_expr.value, indent);
} }
Stmt(loc_expr) => loc_expr.format_with_options(buf, parens, newlines, indent),
} }
} }
} }
@ -357,15 +359,15 @@ pub fn fmt_defs(buf: &mut Buf, defs: &Defs, indent: u16) {
} }
pub fn fmt_body<'a>(buf: &mut Buf, pattern: &'a Pattern<'a>, body: &'a Expr<'a>, indent: u16) { pub fn fmt_body<'a>(buf: &mut Buf, pattern: &'a Pattern<'a>, body: &'a Expr<'a>, indent: u16) {
// Check if this is an assignment into the unit/empty record, format as a Statement // Check if this is an assignment into the unit value
let is_statement = if let Pattern::RecordDestructure(collection) = pattern { let is_unit_assignment = if let Pattern::RecordDestructure(collection) = pattern {
collection.is_empty() collection.is_empty()
} else { } else {
false false
}; };
// Don't format the `{} =` for defs with this pattern // Don't format the `{} =` for defs with this pattern
if !is_statement { if !is_unit_assignment {
pattern.format_with_options(buf, Parens::InApply, Newlines::No, indent); pattern.format_with_options(buf, Parens::InApply, Newlines::No, indent);
buf.indent(indent); buf.indent(indent);
buf.push_str(" ="); buf.push_str(" =");

View file

@ -107,7 +107,6 @@ impl<'a> Formattable for Expr<'a> {
Tuple(fields) => is_collection_multiline(fields), Tuple(fields) => is_collection_multiline(fields),
RecordUpdate { fields, .. } => is_collection_multiline(fields), RecordUpdate { fields, .. } => is_collection_multiline(fields),
RecordBuilder(fields) => is_collection_multiline(fields), RecordBuilder(fields) => is_collection_multiline(fields),
Suffixed(subexpr) => subexpr.is_multiline(),
} }
} }
@ -168,7 +167,11 @@ impl<'a> Formattable for Expr<'a> {
Str(literal) => { Str(literal) => {
fmt_str_literal(buf, *literal, indent); fmt_str_literal(buf, *literal, indent);
} }
Var { module_name, ident } => { Var {
module_name,
ident,
suffixed,
} => {
buf.indent(indent); buf.indent(indent);
if !module_name.is_empty() { if !module_name.is_empty() {
buf.push_str(module_name); buf.push_str(module_name);
@ -176,6 +179,11 @@ impl<'a> Formattable for Expr<'a> {
} }
buf.push_str(ident); buf.push_str(ident);
let count: u8 = *suffixed;
for _ in 0..count {
buf.push('!');
}
} }
Underscore(name) => { Underscore(name) => {
buf.indent(indent); buf.indent(indent);
@ -513,10 +521,6 @@ impl<'a> Formattable for Expr<'a> {
MultipleRecordBuilders { .. } => {} MultipleRecordBuilders { .. } => {}
UnappliedRecordBuilder { .. } => {} UnappliedRecordBuilder { .. } => {}
IngestedFile(_, _) => {} IngestedFile(_, _) => {}
Suffixed(sub_expr) => {
sub_expr.format_with_options(buf, parens, newlines, indent);
buf.push('!');
}
} }
} }
} }

View file

@ -2,7 +2,6 @@ use crate::annotation::{Formattable, Newlines, Parens};
use crate::expr::{fmt_str_literal, format_sq_literal}; use crate::expr::{fmt_str_literal, format_sq_literal};
use crate::spaces::{fmt_comments_only, fmt_spaces, NewlineAt, INDENT}; use crate::spaces::{fmt_comments_only, fmt_spaces, NewlineAt, INDENT};
use crate::Buf; use crate::Buf;
use roc_error_macros::internal_error;
use roc_parse::ast::{Base, CommentOrNewline, Pattern, PatternAs}; use roc_parse::ast::{Base, CommentOrNewline, Pattern, PatternAs};
pub fn fmt_pattern<'a>(buf: &mut Buf, pattern: &'a Pattern<'a>, indent: u16, parens: Parens) { pub fn fmt_pattern<'a>(buf: &mut Buf, pattern: &'a Pattern<'a>, indent: u16, parens: Parens) {
@ -65,7 +64,7 @@ impl<'a> Formattable for Pattern<'a> {
} }
}, },
Pattern::Identifier(_) Pattern::Identifier { .. }
| Pattern::Tag(_) | Pattern::Tag(_)
| Pattern::OpaqueRef(_) | Pattern::OpaqueRef(_)
| Pattern::Apply(_, _) | Pattern::Apply(_, _)
@ -82,7 +81,6 @@ impl<'a> Formattable for Pattern<'a> {
Pattern::Tuple(patterns) | Pattern::List(patterns) => { Pattern::Tuple(patterns) | Pattern::List(patterns) => {
patterns.iter().any(|p| p.is_multiline()) patterns.iter().any(|p| p.is_multiline())
} }
Pattern::Stmt(_) => true,
} }
} }
@ -90,9 +88,16 @@ impl<'a> Formattable for Pattern<'a> {
use self::Pattern::*; use self::Pattern::*;
match self { match self {
Identifier(string) => { Identifier {
ident: string,
suffixed,
} => {
buf.indent(indent); buf.indent(indent);
buf.push_str(string) buf.push_str(string);
for _ in 0..*suffixed {
buf.push('!');
}
} }
Tag(name) | OpaqueRef(name) => { Tag(name) | OpaqueRef(name) => {
buf.indent(indent); buf.indent(indent);
@ -272,19 +277,23 @@ impl<'a> Formattable for Pattern<'a> {
buf.indent(indent); buf.indent(indent);
buf.push_str(string); buf.push_str(string);
} }
QualifiedIdentifier { module_name, ident } => { QualifiedIdentifier {
module_name,
ident,
suffixed,
} => {
buf.indent(indent); buf.indent(indent);
if !module_name.is_empty() { if !module_name.is_empty() {
buf.push_str(module_name); buf.push_str(module_name);
buf.push('.'); buf.push('.');
} }
buf.push_str(ident); for _ in 0..*suffixed {
buf.push('!');
} }
// Statement e.g. Suffixed with optional `{}=` buf.push_str(ident);
// e.g. `Stdout.line! "Hello World"` }
Stmt(_) => internal_error!("should be desugared in parser into alternate pattern"),
} }
} }
} }

View file

@ -567,6 +567,7 @@ impl<'a> RemoveSpaces<'a> for ValueDef<'a> {
condition: arena.alloc(condition.remove_spaces(arena)), condition: arena.alloc(condition.remove_spaces(arena)),
preceding_comment: Region::zero(), preceding_comment: Region::zero(),
}, },
Stmt(loc_expr) => Stmt(arena.alloc(loc_expr.remove_spaces(arena))),
} }
} }
} }
@ -692,7 +693,15 @@ impl<'a> RemoveSpaces<'a> for Expr<'a> {
Expr::Record(a) => Expr::Record(a.remove_spaces(arena)), Expr::Record(a) => Expr::Record(a.remove_spaces(arena)),
Expr::RecordBuilder(a) => Expr::RecordBuilder(a.remove_spaces(arena)), Expr::RecordBuilder(a) => Expr::RecordBuilder(a.remove_spaces(arena)),
Expr::Tuple(a) => Expr::Tuple(a.remove_spaces(arena)), Expr::Tuple(a) => Expr::Tuple(a.remove_spaces(arena)),
Expr::Var { module_name, ident, suffixed } => Expr::Var { module_name, ident, suffixed }, Expr::Var {
module_name,
ident,
suffixed,
} => Expr::Var {
module_name,
ident,
suffixed,
},
Expr::Underscore(a) => Expr::Underscore(a), Expr::Underscore(a) => Expr::Underscore(a),
Expr::Tag(a) => Expr::Tag(a), Expr::Tag(a) => Expr::Tag(a),
Expr::OpaqueRef(a) => Expr::OpaqueRef(a), Expr::OpaqueRef(a) => Expr::OpaqueRef(a),
@ -761,7 +770,6 @@ impl<'a> RemoveSpaces<'a> for Expr<'a> {
Expr::SpaceBefore(a, _) => a.remove_spaces(arena), Expr::SpaceBefore(a, _) => a.remove_spaces(arena),
Expr::SpaceAfter(a, _) => a.remove_spaces(arena), Expr::SpaceAfter(a, _) => a.remove_spaces(arena),
Expr::SingleQuote(a) => Expr::Num(a), Expr::SingleQuote(a) => Expr::Num(a),
Expr::Suffixed(a) => a.remove_spaces(arena),
} }
} }
} }
@ -792,7 +800,7 @@ fn remove_spaces_bad_ident(ident: BadIdent) -> BadIdent {
impl<'a> RemoveSpaces<'a> for Pattern<'a> { impl<'a> RemoveSpaces<'a> for Pattern<'a> {
fn remove_spaces(&self, arena: &'a Bump) -> Self { fn remove_spaces(&self, arena: &'a Bump) -> Self {
match *self { match *self {
Pattern::Identifier(a) => Pattern::Identifier(a), Pattern::Identifier { ident, suffixed } => Pattern::Identifier { ident, suffixed },
Pattern::Tag(a) => Pattern::Tag(a), Pattern::Tag(a) => Pattern::Tag(a),
Pattern::OpaqueRef(a) => Pattern::OpaqueRef(a), Pattern::OpaqueRef(a) => Pattern::OpaqueRef(a),
Pattern::Apply(a, b) => Pattern::Apply( Pattern::Apply(a, b) => Pattern::Apply(
@ -825,9 +833,15 @@ impl<'a> RemoveSpaces<'a> for Pattern<'a> {
Pattern::Underscore(a) => Pattern::Underscore(a), Pattern::Underscore(a) => Pattern::Underscore(a),
Pattern::Malformed(a) => Pattern::Malformed(a), Pattern::Malformed(a) => Pattern::Malformed(a),
Pattern::MalformedIdent(a, b) => Pattern::MalformedIdent(a, remove_spaces_bad_ident(b)), Pattern::MalformedIdent(a, b) => Pattern::MalformedIdent(a, remove_spaces_bad_ident(b)),
Pattern::QualifiedIdentifier { module_name, ident } => { Pattern::QualifiedIdentifier {
Pattern::QualifiedIdentifier { module_name, ident } module_name,
} ident,
suffixed,
} => Pattern::QualifiedIdentifier {
module_name,
ident,
suffixed,
},
Pattern::SpaceBefore(a, _) => a.remove_spaces(arena), Pattern::SpaceBefore(a, _) => a.remove_spaces(arena),
Pattern::SpaceAfter(a, _) => a.remove_spaces(arena), Pattern::SpaceAfter(a, _) => a.remove_spaces(arena),
Pattern::SingleQuote(a) => Pattern::SingleQuote(a), Pattern::SingleQuote(a) => Pattern::SingleQuote(a),
@ -837,7 +851,6 @@ impl<'a> RemoveSpaces<'a> for Pattern<'a> {
opt_pattern_as opt_pattern_as
.map(|(_, pattern_as)| ([].as_ref(), pattern_as.remove_spaces(arena))), .map(|(_, pattern_as)| ([].as_ref(), pattern_as.remove_spaces(arena))),
), ),
Pattern::Stmt(a) => Pattern::Stmt(a),
} }
} }
} }

View file

@ -212,7 +212,12 @@ fn generate_entry_docs(
match either_index.split() { match either_index.split() {
Err(value_index) => match &defs.value_defs[value_index.index()] { Err(value_index) => match &defs.value_defs[value_index.index()] {
ValueDef::Annotation(loc_pattern, loc_ann) => { ValueDef::Annotation(loc_pattern, loc_ann) => {
if let Pattern::Identifier(identifier) = loc_pattern.value { // TODO is this right for suffixed??
if let Pattern::Identifier {
ident: identifier,
suffixed: _,
} = loc_pattern.value
{
// Check if this module exposes the def // Check if this module exposes the def
if let Some(ident_id) = ident_ids.get_id(identifier) { if let Some(ident_id) = ident_ids.get_id(identifier) {
let name = identifier.to_string(); let name = identifier.to_string();
@ -233,7 +238,12 @@ fn generate_entry_docs(
ann_type, ann_type,
.. ..
} => { } => {
if let Pattern::Identifier(identifier) = ann_pattern.value { // TODO is this right for suffixed??
if let Pattern::Identifier {
ident: identifier,
suffixed: _,
} = ann_pattern.value
{
// Check if this module exposes the def // Check if this module exposes the def
if let Some(ident_id) = ident_ids.get_id(identifier) { if let Some(ident_id) = ident_ids.get_id(identifier) {
let doc_def = DocDef { let doc_def = DocDef {
@ -249,7 +259,12 @@ fn generate_entry_docs(
} }
ValueDef::Body(pattern, _) => { ValueDef::Body(pattern, _) => {
if let Pattern::Identifier(identifier) = pattern.value { // TODO is this right for suffixed??
if let Pattern::Identifier {
ident: identifier,
suffixed: _,
} = pattern.value
{
// Check if this module exposes the def // Check if this module exposes the def
if let Some(ident_id) = ident_ids.get_id(identifier) { if let Some(ident_id) = ident_ids.get_id(identifier) {
let doc_def = DocDef { let doc_def = DocDef {
@ -275,6 +290,8 @@ fn generate_entry_docs(
ValueDef::ExpectFx { .. } => { ValueDef::ExpectFx { .. } => {
// Don't generate docs for `expect-fx`s // Don't generate docs for `expect-fx`s
} }
ValueDef::Stmt(_) => todo!(),
}, },
Ok(type_index) => match &defs.type_defs[type_index.index()] { Ok(type_index) => match &defs.type_defs[type_index.index()] {
@ -285,7 +302,12 @@ fn generate_entry_docs(
let mut type_vars = Vec::new(); let mut type_vars = Vec::new();
for var in vars.iter() { for var in vars.iter() {
if let Pattern::Identifier(ident_name) = var.value { // TODO is this right for suffixed??
if let Pattern::Identifier {
ident: ident_name,
suffixed: _,
} = var.value
{
type_vars.push(ident_name.to_string()); type_vars.push(ident_name.to_string());
} }
} }
@ -319,7 +341,12 @@ fn generate_entry_docs(
let mut type_vars = Vec::new(); let mut type_vars = Vec::new();
for var in vars.iter() { for var in vars.iter() {
if let Pattern::Identifier(ident_name) = var.value { // TODO is this right for suffixed??
if let Pattern::Identifier {
ident: ident_name,
suffixed: _,
} = var.value
{
type_vars.push(ident_name.to_string()); type_vars.push(ident_name.to_string());
} }
} }
@ -343,7 +370,12 @@ fn generate_entry_docs(
let mut type_vars = Vec::new(); let mut type_vars = Vec::new();
for var in vars.iter() { for var in vars.iter() {
if let Pattern::Identifier(ident_name) = var.value { // TODO is this right for suffixed??
if let Pattern::Identifier {
ident: ident_name,
suffixed: _,
} = var.value
{
type_vars.push(ident_name.to_string()); type_vars.push(ident_name.to_string());
} }
} }
@ -605,7 +637,8 @@ fn type_to_docs(in_func_type_ann: bool, type_annotation: ast::TypeAnnotation) ->
.vars .vars
.iter() .iter()
.filter_map(|loc_pattern| match loc_pattern.value { .filter_map(|loc_pattern| match loc_pattern.value {
ast::Pattern::Identifier(ident) => Some(ident.to_string()), // TODO is this right for suffixed??
ast::Pattern::Identifier { ident, suffixed: _ } => Some(ident.to_string()),
_ => None, _ => None,
}) })
.collect(), .collect(),

View file

@ -5647,7 +5647,15 @@ fn value_def_from_imports<'a>(
); );
}; };
let typed_ident = typed_ident.extract_spaces().item; let typed_ident = typed_ident.extract_spaces().item;
let ident = arena.alloc(typed_ident.ident.map_owned(Pattern::Identifier)); let Loc { region, value } = typed_ident.ident;
let ident = arena.alloc(Loc::at(
region,
Pattern::Identifier {
ident: value,
suffixed: 0,
},
));
let ann_type = arena.alloc(typed_ident.ann); let ann_type = arena.alloc(typed_ident.ann);
Some(ValueDef::AnnotatedBody { Some(ValueDef::AnnotatedBody {
ann_pattern: ident, ann_pattern: ident,

View file

@ -267,9 +267,6 @@ pub enum Expr<'a> {
// Collection Literals // Collection Literals
List(Collection<'a, &'a Loc<Expr<'a>>>), List(Collection<'a, &'a Loc<Expr<'a>>>),
/// An expression followed by `!``
Suffixed(&'a Expr<'a>),
RecordUpdate { RecordUpdate {
update: &'a Loc<Expr<'a>>, update: &'a Loc<Expr<'a>>,
fields: Collection<'a, Loc<AssignedField<'a, Expr<'a>>>>, fields: Collection<'a, Loc<AssignedField<'a, Expr<'a>>>>,
@ -349,6 +346,25 @@ pub enum Expr<'a> {
UnappliedRecordBuilder(&'a Loc<Expr<'a>>), UnappliedRecordBuilder(&'a Loc<Expr<'a>>),
} }
pub fn is_loc_expr_suffixed(loc_expr: Loc<Expr>) -> bool {
match loc_expr.value.extract_spaces().item {
// expression without arguments, `read!`
Expr::Var { suffixed, .. } => suffixed > 0,
// expression with arguments, `line! "Foo"`
Expr::Apply(sub_loc_expr, _, _) => is_loc_expr_suffixed(*sub_loc_expr),
_ => false,
}
}
pub fn is_valid_suffixed_statement(loc_expr: Loc<Expr>) -> bool {
match loc_expr.extract_spaces().item {
Expr::Var { suffixed, .. } => suffixed > 0,
Expr::Apply(sub_loc_expr, _, _) => is_valid_suffixed_statement(*sub_loc_expr),
_ => false,
}
}
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
pub struct PrecedenceConflict<'a> { pub struct PrecedenceConflict<'a> {
pub whole_region: Region, pub whole_region: Region,
@ -459,6 +475,8 @@ pub enum ValueDef<'a> {
condition: &'a Loc<Expr<'a>>, condition: &'a Loc<Expr<'a>>,
preceding_comment: Region, preceding_comment: Region,
}, },
Stmt(&'a Loc<Expr<'a>>),
} }
#[derive(Debug, Clone, PartialEq, Default)] #[derive(Debug, Clone, PartialEq, Default)]
@ -495,6 +513,47 @@ impl<'a> Defs<'a> {
}) })
} }
// We could have a type annotation as the last tag,
// this helper ensures we refer to the last value_def
// and that we remove the correct tag
pub fn last_value_suffixed(&self) -> Option<(Self, &'a Loc<Expr<'a>>)> {
let value_indexes =
self.tags
.clone()
.into_iter()
.enumerate()
.filter_map(|(tag_index, tag)| match tag.split() {
Ok(_) => None,
Err(value_index) => Some((tag_index, value_index.index())),
});
if let Some((tag_index, value_index)) = value_indexes.last() {
match self.value_defs[value_index] {
ValueDef::Body(
Loc {
value: Pattern::RecordDestructure(collection),
..
},
loc_expr,
) if collection.is_empty() && is_loc_expr_suffixed(*loc_expr) => {
let mut new_defs = self.clone();
new_defs.remove_value_def(tag_index);
return Some((new_defs, loc_expr));
}
ValueDef::Stmt(loc_expr) if is_loc_expr_suffixed(*loc_expr) => {
let mut new_defs = self.clone();
new_defs.remove_value_def(tag_index);
return Some((new_defs, loc_expr));
}
_ => {}
}
}
None
}
pub fn remove_value_def(&mut self, index: usize) { pub fn remove_value_def(&mut self, index: usize) {
match self match self
.tags .tags
@ -601,16 +660,8 @@ impl<'a> Defs<'a> {
if let Err(value_index) = tag.split() { if let Err(value_index) = tag.split() {
let index = value_index.index(); let index = value_index.index();
if let ValueDef::Body(_, expr) = &self.value_defs[index] { if let ValueDef::Body(_, loc_expr) = &self.value_defs[index] {
// The Suffixed has arguments applied e.g. `Stdout.line! "Hello World"` if is_loc_expr_suffixed(**loc_expr) {
if let Expr::Apply(sub_expr, _, _) = expr.value {
if let Expr::Suffixed(_) = sub_expr.value {
return Some((tag_index, index));
}
}
// The Suffixed has NO arguments applied e.g. `Stdin.line!`
if let Expr::Suffixed(_) = expr.value {
return Some((tag_index, index)); return Some((tag_index, index));
} }
} }
@ -872,10 +923,14 @@ impl<'a> PatternAs<'a> {
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
pub enum Pattern<'a> { pub enum Pattern<'a> {
// Identifier // Identifier
Identifier(&'a str), Identifier {
ident: &'a str,
suffixed: u8,
},
QualifiedIdentifier { QualifiedIdentifier {
module_name: &'a str, module_name: &'a str,
ident: &'a str, ident: &'a str,
suffixed: u8,
}, },
Tag(&'a str), Tag(&'a str),
@ -928,11 +983,10 @@ pub enum Pattern<'a> {
// Malformed // Malformed
Malformed(&'a str), Malformed(&'a str),
MalformedIdent(&'a str, crate::ident::BadIdent), MalformedIdent(&'a str, crate::ident::BadIdent),
// Statement e.g. `Stdout.line! "Hello"`
Stmt(&'a str),
} }
// pub fn contains_bang_suffixed
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Base { pub enum Base {
Octal, Octal,
@ -996,11 +1050,22 @@ impl<'a> Pattern<'a> {
// { x, y } : { x : Int, y ? Bool } // { x, y } : { x : Int, y ? Bool }
// { x, y ? False } = rec // { x, y ? False } = rec
OptionalField(x, _) => match other { OptionalField(x, _) => match other {
Identifier(y) | OptionalField(y, _) => x == y, Identifier {
ident: y,
suffixed: 0,
}
| OptionalField(y, _) => x == y,
_ => false, _ => false,
}, },
Identifier(x) => match other { Identifier {
Identifier(y) | OptionalField(y, _) => x == y, ident: x,
suffixed: a,
} => match other {
Identifier {
ident: y,
suffixed: b,
} => x == y && a == b,
OptionalField(y, _) => x == y,
_ => false, _ => false,
}, },
NumLiteral(x) => { NumLiteral(x) => {
@ -1061,13 +1126,15 @@ impl<'a> Pattern<'a> {
QualifiedIdentifier { QualifiedIdentifier {
module_name: a, module_name: a,
ident: x, ident: x,
suffixed: i,
} => { } => {
if let QualifiedIdentifier { if let QualifiedIdentifier {
module_name: b, module_name: b,
ident: y, ident: y,
suffixed: j,
} = other } = other
{ {
a == b && x == y a == b && x == y && i == j
} else { } else {
false false
} }
@ -1130,14 +1197,6 @@ impl<'a> Pattern<'a> {
false false
} }
} }
Stmt(str_x) => {
if let Stmt(str_y) = other {
str_x == str_y
} else {
false
}
}
} }
} }
} }
@ -1437,7 +1496,14 @@ macro_rules! impl_extract_spaces {
match self { match self {
$t::SpaceBefore(item, before) => { $t::SpaceBefore(item, before) => {
match item { match item {
$t::SpaceBefore(_, _) => todo!(), $t::SpaceBefore(_, _) => {
// TODO this probably isn't right, but was causing a panic with just todo!()
Spaces {
before,
item: **item,
after: &[],
}
},
$t::SpaceAfter(item, after) => { $t::SpaceAfter(item, after) => {
Spaces { Spaces {
before, before,
@ -1667,7 +1733,6 @@ impl<'a> Malformed for Expr<'a> {
PrecedenceConflict(_) | PrecedenceConflict(_) |
MultipleRecordBuilders(_) | MultipleRecordBuilders(_) |
UnappliedRecordBuilder(_) => true, UnappliedRecordBuilder(_) => true,
Suffixed(expr) => expr.is_malformed(),
} }
} }
} }
@ -1762,10 +1827,9 @@ impl<'a> Malformed for Pattern<'a> {
use Pattern::*; use Pattern::*;
match self { match self {
Identifier(_) | Identifier{ .. } |
Tag(_) | Tag(_) |
OpaqueRef(_) | OpaqueRef(_) => false,
Stmt(_) => false,
Apply(func, args) => func.is_malformed() || args.iter().any(|arg| arg.is_malformed()), Apply(func, args) => func.is_malformed() || args.iter().any(|arg| arg.is_malformed()),
RecordDestructure(items) => items.iter().any(|item| item.is_malformed()), RecordDestructure(items) => items.iter().any(|item| item.is_malformed()),
RequiredField(_, pat) => pat.is_malformed(), RequiredField(_, pat) => pat.is_malformed(),
@ -1903,6 +1967,7 @@ impl<'a> Malformed for ValueDef<'a> {
condition, condition,
preceding_comment: _, preceding_comment: _,
} => condition.is_malformed(), } => condition.is_malformed(),
ValueDef::Stmt(loc_expr) => loc_expr.is_malformed(),
} }
} }
} }

View file

@ -1,7 +1,7 @@
use crate::ast::{ use crate::ast::{
AssignedField, Collection, CommentOrNewline, Defs, Expr, ExtractSpaces, Implements, is_valid_suffixed_statement, AssignedField, Collection, CommentOrNewline, Defs, Expr,
ImplementsAbilities, Pattern, RecordBuilderField, Spaceable, Spaces, TypeAnnotation, TypeDef, ExtractSpaces, Implements, ImplementsAbilities, Pattern, RecordBuilderField, Spaceable, Spaces,
TypeHeader, ValueDef, TypeAnnotation, TypeDef, TypeHeader, ValueDef,
}; };
use crate::blankspace::{ use crate::blankspace::{
space0_after_e, space0_around_e_no_after_indent_check, space0_around_ee, space0_before_e, space0_after_e, space0_around_e_no_after_indent_check, space0_around_ee, space0_before_e,
@ -321,25 +321,13 @@ fn expr_start<'a>(options: ExprParseOptions) -> impl Parser<'a, Loc<Expr<'a>>, E
fn expr_operator_chain<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a>, EExpr<'a>> { fn expr_operator_chain<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a>, EExpr<'a>> {
line_min_indent(move |arena, state: State<'a>, min_indent: u32| { line_min_indent(move |arena, state: State<'a>, min_indent: u32| {
let (_, expr, state, new_min_indent) = loc_possibly_negative_or_negated_term(options) let (_, expr, state) =
.parse(arena, state, min_indent) loc_possibly_negative_or_negated_term(options).parse(arena, state, min_indent)?;
.map(|(progress, loc_expr, state)| {
// For multi-line suffixed expressions, the following lines need to be indented e.g.
// ```roc
// Stdout.line
// "Hello World"
// ```
if is_loc_expr_suffixed(loc_expr) {
(progress, loc_expr, state, min_indent + 1)
} else {
(progress, loc_expr, state, min_indent)
}
})?;
let initial_state = state.clone(); let initial_state = state.clone();
let end = state.pos(); let end = state.pos();
match space0_e(EExpr::IndentEnd).parse(arena, state.clone(), new_min_indent) { match space0_e(EExpr::IndentEnd).parse(arena, state.clone(), min_indent) {
Err((_, _)) => Ok((MadeProgress, expr.value, state)), Err((_, _)) => Ok((MadeProgress, expr.value, state)),
Ok((_, spaces_before_op, state)) => { Ok((_, spaces_before_op, state)) => {
let expr_state = ExprState { let expr_state = ExprState {
@ -350,14 +338,7 @@ fn expr_operator_chain<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a
end, end,
}; };
parse_expr_end( parse_expr_end(min_indent, options, expr_state, arena, state, initial_state)
new_min_indent,
options,
expr_state,
arena,
state,
initial_state,
)
} }
} }
}) })
@ -633,59 +614,34 @@ pub fn parse_single_def<'a>(
// a hacky way to get expression-based error messages. TODO fix this // a hacky way to get expression-based error messages. TODO fix this
Ok((NoProgress, None, initial)) Ok((NoProgress, None, initial))
} }
// Check if we have a Statement with Suffixed first,
// re-parse the state as an expression
// and then use a `{}=` pattern for the ValueDef::Body.
Ok((
MadeProgress,
Loc {
region,
value: Pattern::Stmt(_),
..
},
_,
))
| Ok((
MadeProgress,
Loc {
region,
value: Pattern::SpaceAfter(Pattern::Stmt(_), _),
..
},
_,
))
| Ok((
MadeProgress,
Loc {
region,
value: Pattern::SpaceBefore(Pattern::Stmt(_), _),
..
},
_,
)) => {
let parse_def_expr =
space0_before_e(increment_min_indent(expr_start(options)), EExpr::IndentEnd);
let (_, loc_def_expr, updated_state) =
parse_def_expr.parse(arena, state, min_indent)?;
let loc_pattern = Loc::at(region, Pattern::RecordDestructure(Collection::empty()));
let value_def = ValueDef::Body(arena.alloc(loc_pattern), &*arena.alloc(loc_def_expr));
let region = Region::span_across(&loc_pattern.region, &loc_def_expr.region);
Ok((
MadeProgress,
Some(SingleDef {
type_or_value: Either::Second(value_def),
region,
spaces_before: spaces_before_current,
}),
updated_state,
))
}
Ok((_, loc_pattern, state)) => { Ok((_, loc_pattern, state)) => {
// // Check if we have a Statement with Suffixed first,
// // re-parse the state as an expression
// // and then use a `{}=` pattern for the ValueDef::Body.
// if is_statement {
// let parse_def_expr =
// space0_before_e(increment_min_indent(expr_start(options)), EExpr::IndentEnd);
// let (_, loc_def_expr, updated_state) =
// parse_def_expr.parse(arena, state, min_indent)?;
// let loc_pattern = Loc::at(region, Pattern::RecordDestructure(Collection::empty()));
// let value_def = ValueDef::Body(arena.alloc(loc_pattern), &*arena.alloc(loc_def_expr));
// let region = Region::span_across(&loc_pattern.region, &loc_def_expr.region);
// Ok((
// MadeProgress,
// Some(SingleDef {
// type_or_value: Either::Second(value_def),
// region,
// spaces_before: spaces_before_current,
// }),
// updated_state,
// ))
// }
// First let's check whether this is an ability definition. // First let's check whether this is an ability definition.
let opt_tag_and_args: Option<(&str, Region, &[Loc<Pattern>])> = match loc_pattern.value let opt_tag_and_args: Option<(&str, Region, &[Loc<Pattern>])> = match loc_pattern.value
{ {
@ -725,24 +681,22 @@ pub fn parse_single_def<'a>(
} }
} }
// Otherwise, this is a def or alias. // This may be a def or alias.
match operator().parse(arena, state, min_indent) { let operator_result = operator().parse(arena, state.clone(), min_indent);
Ok((_, BinOp::Assignment, state)) => {
let parse_def_expr = space0_before_e(
increment_min_indent(expr_start(options)),
EExpr::IndentEnd,
);
let (_, loc_def_expr, state) = if let Ok((_, BinOp::Assignment, state)) = operator_result {
parse_def_expr.parse(arena, state, min_indent)?; let parse_def_expr =
space0_before_e(increment_min_indent(expr_start(options)), EExpr::IndentEnd);
let (_, loc_def_expr, state) = parse_def_expr.parse(arena, state, min_indent)?;
let value_def = let value_def =
ValueDef::Body(arena.alloc(loc_pattern), &*arena.alloc(loc_def_expr)); ValueDef::Body(arena.alloc(loc_pattern), &*arena.alloc(loc_def_expr));
let region = Region::span_across(&loc_pattern.region, &loc_def_expr.region); let region = Region::span_across(&loc_pattern.region, &loc_def_expr.region);
// Handle the specific case when the first line of an assignment is actually a suffixed statement // Handle the specific case when the first line of an assignment is actually a suffixed statement
if is_loc_expr_suffixed(loc_def_expr) { if crate::ast::is_loc_expr_suffixed(loc_def_expr) {
// Take the suffixed value and make it a e.g. Body(`{}=`, Apply(Suffixed(...))) // Take the suffixed value and make it a e.g. Body(`{}=`, Apply(Var(...)))
// we will keep the pattern `loc_pattern` for the new Defs // we will keep the pattern `loc_pattern` for the new Defs
let mut defs = Defs::default(); let mut defs = Defs::default();
defs.push_value_def( defs.push_value_def(
@ -751,10 +705,7 @@ pub fn parse_single_def<'a>(
region, region,
Pattern::RecordDestructure(Collection::empty()), Pattern::RecordDestructure(Collection::empty()),
)), )),
arena.alloc(Loc::at( arena.alloc(Loc::at(region, loc_def_expr.value.extract_spaces().item)),
region,
loc_def_expr.value.extract_spaces().item,
)),
), ),
region, region,
&[], &[],
@ -764,6 +715,70 @@ pub fn parse_single_def<'a>(
let (progress, expr, state_post_defs) = let (progress, expr, state_post_defs) =
parse_defs_expr(options, min_indent, defs, arena, state.clone())?; parse_defs_expr(options, min_indent, defs, arena, state.clone())?;
// let parse_defs_expr_result = dbg!(parse_defs_expr(
// options,
// min_indent + 1,
// defs.clone(),
// arena,
// state_after_def_expr.clone(),
// ));
// if let Err((err_progress, EExpr::DefMissingFinalExpr2(expr2, pos))) =
// parse_defs_expr_result
// {
// let defs_copy = defs.clone();
// // Try to de-sugar `!` a suffix if it is the final expression
// if let Some(ValueDef::Body(body_loc_pattern, loc_expr)) =
// defs_copy.value_defs.last()
// {
// if let Pattern::RecordDestructure(record) =
// body_loc_pattern.extract_spaces().item
// {
// if record.is_empty() && is_loc_expr_suffixed(**loc_expr) {
// // remove the last value_def and extract the Suffixed value
// // to be the return expression ret_loc
// let mut new_defs_copy = defs_copy.clone();
// dbg!(&new_defs_copy);
// new_defs_copy.remove_value_def(
// new_defs_copy.tags.len().saturating_sub(1),
// );
// dbg!(&new_defs_copy);
// let loc_ret = if new_defs_copy.len() <= 1 {
// extract_suffixed_expr(arena, **loc_expr)
// } else {
// arena.alloc(Loc::at(
// region,
// Expr::Defs(
// arena.alloc(new_defs_copy),
// extract_suffixed_expr(arena, **loc_expr),
// ),
// ))
// };
// return Ok((
// MadeProgress,
// Some(SingleDef {
// type_or_value: Either::Second(ValueDef::Body(
// arena.alloc(loc_pattern),
// loc_ret,
// )),
// region,
// spaces_before: spaces_before_current,
// }),
// state_after_def_expr.clone(),
// ));
// }
// }
// }
// return Err((err_progress, EExpr::DefMissingFinalExpr2(expr2, pos)));
// } else if let Ok((progress, expr, state_after_parse_defs_expr)) =
// parse_defs_expr_result
// {
return Ok(( return Ok((
progress, progress,
Some(SingleDef { Some(SingleDef {
@ -776,9 +791,13 @@ pub fn parse_single_def<'a>(
}), }),
state_post_defs, state_post_defs,
)); ));
// } else {
// parse_defs_expr_result?;
// };
} }
Ok(( return Ok((
MadeProgress, MadeProgress,
Some(SingleDef { Some(SingleDef {
type_or_value: Either::Second(value_def), type_or_value: Either::Second(value_def),
@ -786,9 +805,10 @@ pub fn parse_single_def<'a>(
spaces_before: spaces_before_current, spaces_before: spaces_before_current,
}), }),
state, state,
)) ));
} }
Ok((_, BinOp::IsAliasType, state)) => {
if let Ok((_, BinOp::IsAliasType, state)) = operator_result {
// the increment_min_indent here is probably _wrong_, since alias_signature_with_space_before does // the increment_min_indent here is probably _wrong_, since alias_signature_with_space_before does
// that internally. // that internally.
// TODO: re-evaluate this // TODO: re-evaluate this
@ -815,7 +835,7 @@ pub fn parse_single_def<'a>(
ann: ann_type, ann: ann_type,
}; };
Ok(( return Ok((
MadeProgress, MadeProgress,
Some(SingleDef { Some(SingleDef {
type_or_value: Either::First(type_def), type_or_value: Either::First(type_def),
@ -823,7 +843,7 @@ pub fn parse_single_def<'a>(
spaces_before: spaces_before_current, spaces_before: spaces_before_current,
}), }),
state, state,
)) ));
} }
Pattern::Tag(name) => { Pattern::Tag(name) => {
let name = Loc::at(loc_pattern.region, *name); let name = Loc::at(loc_pattern.region, *name);
@ -838,7 +858,7 @@ pub fn parse_single_def<'a>(
ann: ann_type, ann: ann_type,
}; };
Ok(( return Ok((
MadeProgress, MadeProgress,
Some(SingleDef { Some(SingleDef {
type_or_value: Either::First(type_def), type_or_value: Either::First(type_def),
@ -846,12 +866,12 @@ pub fn parse_single_def<'a>(
spaces_before: spaces_before_current, spaces_before: spaces_before_current,
}), }),
state, state,
)) ));
} }
_ => { _ => {
let value_def = ValueDef::Annotation(loc_pattern, ann_type); let value_def = ValueDef::Annotation(loc_pattern, ann_type);
Ok(( return Ok((
MadeProgress, MadeProgress,
Some(SingleDef { Some(SingleDef {
type_or_value: Either::Second(value_def), type_or_value: Either::Second(value_def),
@ -859,11 +879,12 @@ pub fn parse_single_def<'a>(
spaces_before: spaces_before_current, spaces_before: spaces_before_current,
}), }),
state, state,
)) ));
} }
} }
} };
Ok((_, BinOp::IsOpaqueType, state)) => {
if let Ok((_, BinOp::IsOpaqueType, state)) = operator_result {
let (_, (signature, derived), state) = let (_, (signature, derived), state) =
opaque_signature_with_space_before().parse(arena, state, min_indent + 1)?; opaque_signature_with_space_before().parse(arena, state, min_indent + 1)?;
let region = Region::span_across(&loc_pattern.region, &signature.region); let region = Region::span_across(&loc_pattern.region, &signature.region);
@ -888,7 +909,7 @@ pub fn parse_single_def<'a>(
derived, derived,
}; };
Ok(( return Ok((
MadeProgress, MadeProgress,
Some(SingleDef { Some(SingleDef {
type_or_value: Either::First(type_def), type_or_value: Either::First(type_def),
@ -896,7 +917,7 @@ pub fn parse_single_def<'a>(
spaces_before: spaces_before_current, spaces_before: spaces_before_current,
}), }),
state, state,
)) ));
} }
Pattern::Tag(name) => { Pattern::Tag(name) => {
let name = Loc::at(loc_pattern.region, *name); let name = Loc::at(loc_pattern.region, *name);
@ -912,7 +933,7 @@ pub fn parse_single_def<'a>(
derived, derived,
}; };
Ok(( return Ok((
MadeProgress, MadeProgress,
Some(SingleDef { Some(SingleDef {
type_or_value: Either::First(type_def), type_or_value: Either::First(type_def),
@ -920,12 +941,12 @@ pub fn parse_single_def<'a>(
spaces_before: spaces_before_current, spaces_before: spaces_before_current,
}), }),
state, state,
)) ));
} }
_ => { _ => {
let value_def = ValueDef::Annotation(loc_pattern, signature); let value_def = ValueDef::Annotation(loc_pattern, signature);
Ok(( return Ok((
MadeProgress, MadeProgress,
Some(SingleDef { Some(SingleDef {
type_or_value: Either::Second(value_def), type_or_value: Either::Second(value_def),
@ -933,11 +954,32 @@ pub fn parse_single_def<'a>(
spaces_before: spaces_before_current, spaces_before: spaces_before_current,
}), }),
state, state,
)) ));
} }
} }
};
// Otherwise try to parse as a Statement
match parse_statement_inside_def(
arena,
initial.clone(),
min_indent,
options,
start,
spaces_before_current_start,
// TODO figure out why including spaces_before_current here doubles things up
&[],
|_, loc_def_expr| -> ValueDef<'a> { ValueDef::Stmt(arena.alloc(loc_def_expr)) },
) {
Ok((_, Some(single_def), state)) => match single_def.type_or_value {
Either::Second(ValueDef::Stmt(loc_expr))
if is_valid_suffixed_statement(*loc_expr) =>
{
Ok((MadeProgress, Some(single_def), state))
} }
_ => Ok((MadeProgress, None, initial)), _ => Ok((NoProgress, None, initial)),
},
_ => Ok((NoProgress, None, initial)),
} }
} }
} }
@ -976,6 +1018,7 @@ fn parse_statement_inside_def<'a>(
} }
let preceding_comment = Region::new(spaces_before_current_start, start); let preceding_comment = Region::new(spaces_before_current_start, start);
let value_def = get_value_def(preceding_comment, loc_def_expr); let value_def = get_value_def(preceding_comment, loc_def_expr);
Ok(( Ok((
@ -1142,6 +1185,7 @@ fn parse_defs_end<'a>(
} }
} }
#[derive(Debug)]
pub struct SingleDef<'a> { pub struct SingleDef<'a> {
pub type_or_value: Either<TypeDef<'a>, ValueDef<'a>>, pub type_or_value: Either<TypeDef<'a>, ValueDef<'a>>,
pub region: Region, pub region: Region,
@ -1163,29 +1207,32 @@ fn parse_defs_expr<'a>(
match parse_final_expr.parse(arena, state.clone(), min_indent) { match parse_final_expr.parse(arena, state.clone(), min_indent) {
Err((_, fail)) => { Err((_, fail)) => {
return Err(( // If the last def was a statment, unwrap it and use that as loc_ret
if let Some((new_defs, loc_ret)) = def_state.last_value_suffixed() {
if new_defs.value_defs.len() > 1 {
return Ok((
MadeProgress,
Expr::Defs(arena.alloc(new_defs), arena.alloc(loc_ret)),
state,
));
} else {
return Ok((MadeProgress, loc_ret.value, state));
}
}
Err((
MadeProgress, MadeProgress,
EExpr::DefMissingFinalExpr2(arena.alloc(fail), state.pos()), EExpr::DefMissingFinalExpr2(arena.alloc(fail), state.pos()),
)); ))
} }
Ok((_, loc_ret, state)) => { Ok((_, loc_ret, state)) => Ok((
return Ok((
MadeProgress, MadeProgress,
Expr::Defs(arena.alloc(def_state), arena.alloc(loc_ret)), Expr::Defs(arena.alloc(def_state), arena.alloc(loc_ret)),
state, state,
)); )),
} }
} }
} }
}
}
fn is_loc_expr_suffixed<'a>(loc_expr: Loc<Expr<'a>>) -> bool {
match loc_expr.value.extract_spaces().item {
Expr::Suffixed(_) => true,
Expr::Apply(sub_loc_expr, _, _) => is_loc_expr_suffixed(*sub_loc_expr),
_ => false,
}
} }
fn alias_signature_with_space_before<'a>() -> impl Parser<'a, Loc<TypeAnnotation<'a>>, EExpr<'a>> { fn alias_signature_with_space_before<'a>() -> impl Parser<'a, Loc<TypeAnnotation<'a>>, EExpr<'a>> {
@ -1773,6 +1820,7 @@ fn parse_expr_end<'a>(
Expr::Var { Expr::Var {
module_name: "", module_name: "",
ident: crate::keyword::IMPLEMENTS, ident: crate::keyword::IMPLEMENTS,
..
}, },
.. ..
}, },
@ -1995,11 +2043,19 @@ fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result<Pattern<
} }
let mut pat = match expr.item { let mut pat = match expr.item {
Expr::Var { module_name, ident } => { Expr::Var {
module_name,
ident,
suffixed,
} => {
if module_name.is_empty() { if module_name.is_empty() {
Pattern::Identifier(ident) Pattern::Identifier { ident, suffixed }
} else { } else {
Pattern::QualifiedIdentifier { module_name, ident } Pattern::QualifiedIdentifier {
module_name,
ident,
suffixed,
}
} }
} }
Expr::Underscore(opt_name) => Pattern::Underscore(opt_name), Expr::Underscore(opt_name) => Pattern::Underscore(opt_name),
@ -2083,7 +2139,6 @@ fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result<Pattern<
Expr::Str(string) => Pattern::StrLiteral(string), Expr::Str(string) => Pattern::StrLiteral(string),
Expr::SingleQuote(string) => Pattern::SingleQuote(string), Expr::SingleQuote(string) => Pattern::SingleQuote(string),
Expr::MalformedIdent(string, problem) => Pattern::MalformedIdent(string, problem), Expr::MalformedIdent(string, problem) => Pattern::MalformedIdent(string, problem),
Expr::Suffixed(_) => todo!(),
}; };
// Now we re-add the spaces // Now we re-add the spaces
@ -2133,7 +2188,10 @@ fn assigned_expr_field_to_pattern_help<'a>(
) )
} }
} }
AssignedField::LabelOnly(name) => Pattern::Identifier(name.value), AssignedField::LabelOnly(name) => Pattern::Identifier {
ident: name.value,
suffixed: 0,
},
AssignedField::SpaceBefore(nested, spaces) => Pattern::SpaceBefore( AssignedField::SpaceBefore(nested, spaces) => Pattern::SpaceBefore(
arena.alloc(assigned_expr_field_to_pattern_help(arena, nested)?), arena.alloc(assigned_expr_field_to_pattern_help(arena, nested)?),
spaces, spaces,
@ -2634,10 +2692,11 @@ fn ident_to_expr<'a>(arena: &'a Bump, src: Ident<'a>) -> Expr<'a> {
// The first value in the iterator is the variable name, // The first value in the iterator is the variable name,
// e.g. `foo` in `foo.bar.baz` // e.g. `foo` in `foo.bar.baz`
let mut answer = match iter.next() { let mut answer = match iter.next() {
Some(Accessor::RecordField(ident)) if suffixed => { Some(Accessor::RecordField(ident)) => Expr::Var {
Expr::Suffixed(arena.alloc(Expr::Var { module_name, ident })) module_name,
} ident,
Some(Accessor::RecordField(ident)) => Expr::Var { module_name, ident }, suffixed,
},
Some(Accessor::TupleIndex(_)) => { Some(Accessor::TupleIndex(_)) => {
// TODO: make this state impossible to represent in Ident::Access, // TODO: make this state impossible to represent in Ident::Access,
// by splitting out parts[0] into a separate field with a type of `&'a str`, // by splitting out parts[0] into a separate field with a type of `&'a str`,

View file

@ -51,8 +51,11 @@ pub fn loc_pattern_help<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, EPattern<'a>>
let pattern_state = state.clone(); let pattern_state = state.clone();
// Return early with the suffixed statement // Return early with the suffixed statement
if let Pattern::BangSuffixed(_,_) = pattern.value { match pattern.value {
return Ok((MadeProgress, pattern, pattern_state)); Pattern::Identifier { suffixed, .. } if suffixed > 0 => {
return Ok((MadeProgress, pattern, pattern_state))
}
_ => {}
} }
let (pattern_spaces, state) = let (pattern_spaces, state) =
@ -144,7 +147,15 @@ fn loc_tag_pattern_arg<'a>(
let Loc { region, value } = loc_pat; let Loc { region, value } = loc_pat;
if stop_on_has_kw && matches!(value, Pattern::Identifier(crate::keyword::IMPLEMENTS)) { if stop_on_has_kw
&& matches!(
value,
Pattern::Identifier {
ident: crate::keyword::IMPLEMENTS,
..
}
)
{
Err((NoProgress, EPattern::End(original_state.pos()))) Err((NoProgress, EPattern::End(original_state.pos())))
} else { } else {
Ok(( Ok((
@ -166,7 +177,10 @@ pub fn loc_implements_parser<'a>() -> impl Parser<'a, Loc<Implements<'a>>, EPatt
|_arena, state, progress, pattern| { |_arena, state, progress, pattern| {
if matches!( if matches!(
pattern.value, pattern.value,
Pattern::Identifier(crate::keyword::IMPLEMENTS) Pattern::Identifier {
ident: crate::keyword::IMPLEMENTS,
..
}
) { ) {
Ok(( Ok((
progress, progress,
@ -400,14 +414,17 @@ fn loc_ident_pattern_help<'a>(
} if suffixed > 0 => { } if suffixed > 0 => {
if module_name.is_empty() && parts.len() == 1 { if module_name.is_empty() && parts.len() == 1 {
if let Accessor::RecordField(var) = &parts[0] { if let Accessor::RecordField(var) = &parts[0] {
return Ok(( Ok((
MadeProgress, MadeProgress,
Loc { Loc {
region: loc_ident.region, region: loc_ident.region,
value: Pattern::BangSuffixed(var, suffixed), value: Pattern::Identifier {
ident: var,
suffixed,
},
}, },
state, state,
)); ))
} else { } else {
internal_error!("unexpected suffixed TupleIndex"); internal_error!("unexpected suffixed TupleIndex");
} }
@ -416,7 +433,11 @@ fn loc_ident_pattern_help<'a>(
MadeProgress, MadeProgress,
Loc { Loc {
region: loc_ident.region, region: loc_ident.region,
value: Pattern::BangSuffixed(arena.alloc(format!("{}.{}", module_name, var)), suffixed), value: Pattern::QualifiedIdentifier {
module_name,
ident: var,
suffixed,
},
}, },
state, state,
)); ));
@ -442,7 +463,10 @@ fn loc_ident_pattern_help<'a>(
MadeProgress, MadeProgress,
Loc { Loc {
region: loc_ident.region, region: loc_ident.region,
value: Pattern::Identifier(var), value: Pattern::Identifier {
ident: var,
suffixed: 0,
},
}, },
state, state,
)); ));
@ -603,9 +627,18 @@ fn record_pattern_field<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, PRecord<'a>>
None => { None => {
let Loc { value, region } = loc_label; let Loc { value, region } = loc_label;
let value = if !spaces.is_empty() { let value = if !spaces.is_empty() {
Pattern::SpaceAfter(arena.alloc(Pattern::Identifier(value)), spaces) Pattern::SpaceAfter(
arena.alloc(Pattern::Identifier {
ident: value,
suffixed: 0,
}),
spaces,
)
} else { } else {
Pattern::Identifier(value) Pattern::Identifier {
ident: value,
suffixed: 0,
}
}; };
Ok((MadeProgress, Loc::at(region, value), state)) Ok((MadeProgress, Loc::at(region, value), state))

View file

@ -70,7 +70,13 @@ fn check_type_alias<'a>(
var_names.reserve(vars.len()); var_names.reserve(vars.len());
for var in vars { for var in vars {
if let TypeAnnotation::BoundVariable(v) = var.value { if let TypeAnnotation::BoundVariable(v) = var.value {
var_names.push(Loc::at(var.region, Pattern::Identifier(v))); var_names.push(Loc::at(
var.region,
Pattern::Identifier {
ident: v,
suffixed: 0,
},
));
} else { } else {
return Err(ETypeInlineAlias::ArgumentNotLowercase(var.region.start())); return Err(ETypeInlineAlias::ArgumentNotLowercase(var.region.start()));
} }

View file

@ -175,7 +175,7 @@ mod test_parse {
let expr = arena.alloc(Var { let expr = arena.alloc(Var {
module_name: "", module_name: "",
ident: "name", ident: "name",
suffixed: false, suffixed: 0,
}); });
bumpalo::vec![in arena; bumpalo::vec![in arena;
@ -192,7 +192,7 @@ mod test_parse {
let expr = arena.alloc(Var { let expr = arena.alloc(Var {
module_name: "", module_name: "",
ident: "name", ident: "name",
suffixed: false, suffixed: 0,
}); });
bumpalo::vec![in arena; bumpalo::vec![in arena;
@ -238,7 +238,7 @@ mod test_parse {
let expr = arena.alloc(Var { let expr = arena.alloc(Var {
module_name: "", module_name: "",
ident: "name", ident: "name",
suffixed: false, suffixed: 0,
}); });
bumpalo::vec![in arena; bumpalo::vec![in arena;
@ -254,13 +254,13 @@ mod test_parse {
let expr1 = arena.alloc(Var { let expr1 = arena.alloc(Var {
module_name: "", module_name: "",
ident: "name", ident: "name",
suffixed: false, suffixed: 0,
}); });
let expr2 = arena.alloc(Var { let expr2 = arena.alloc(Var {
module_name: "", module_name: "",
ident: "project", ident: "project",
suffixed: false, suffixed: 0,
}); });
bumpalo::vec![in arena; bumpalo::vec![in arena;
@ -281,13 +281,13 @@ mod test_parse {
let expr1 = arena.alloc(Var { let expr1 = arena.alloc(Var {
module_name: "", module_name: "",
ident: "name", ident: "name",
suffixed: false, suffixed: 0,
}); });
let expr2 = arena.alloc(Var { let expr2 = arena.alloc(Var {
module_name: "", module_name: "",
ident: "project", ident: "project",
suffixed: false, suffixed: 0,
}); });
bumpalo::vec![in arena; bumpalo::vec![in arena;

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-3 Identifier( @0-3 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
@6-27 TagUnion { @6-27 TagUnion {
ext: None, ext: None,
tags: [ tags: [
@ -40,9 +41,10 @@ Defs(
}, },
), ),
AnnotatedBody { AnnotatedBody {
ann_pattern: @0-3 Identifier( ann_pattern: @0-3 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
ann_type: @6-27 TagUnion { ann_type: @6-27 TagUnion {
ext: None, ext: None,
tags: [ tags: [
@ -63,9 +65,10 @@ Defs(
], ],
}, },
comment: None, comment: None,
body_pattern: @28-31 Identifier( body_pattern: @28-31 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
body_expr: @34-38 Tag( body_expr: @34-38 Tag(
"True", "True",
), ),

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-3 Identifier( @0-3 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
@6-28 TagUnion { @6-28 TagUnion {
ext: Some( ext: Some(
@27-28 Wildcard, @27-28 Wildcard,
@ -42,9 +43,10 @@ Defs(
}, },
), ),
AnnotatedBody { AnnotatedBody {
ann_pattern: @0-3 Identifier( ann_pattern: @0-3 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
ann_type: @6-28 TagUnion { ann_type: @6-28 TagUnion {
ext: Some( ext: Some(
@27-28 Wildcard, @27-28 Wildcard,
@ -67,9 +69,10 @@ Defs(
], ],
}, },
comment: None, comment: None,
body_pattern: @29-32 Identifier( body_pattern: @29-32 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
body_expr: @35-39 Tag( body_expr: @35-39 Tag(
"True", "True",
), ),

View file

@ -18,12 +18,14 @@ Defs(
Annotation( Annotation(
@0-8 RecordDestructure( @0-8 RecordDestructure(
[ [
@2-3 Identifier( @2-3 Identifier {
"x", ident: "x",
), suffixed: 0,
@5-7 Identifier( },
"y", @5-7 Identifier {
), ident: "y",
suffixed: 0,
},
], ],
), ),
@11-14 Apply( @11-14 Apply(
@ -35,12 +37,14 @@ Defs(
AnnotatedBody { AnnotatedBody {
ann_pattern: @0-8 RecordDestructure( ann_pattern: @0-8 RecordDestructure(
[ [
@2-3 Identifier( @2-3 Identifier {
"x", ident: "x",
), suffixed: 0,
@5-7 Identifier( },
"y", @5-7 Identifier {
), ident: "y",
suffixed: 0,
},
], ],
), ),
ann_type: @11-14 Apply( ann_type: @11-14 Apply(
@ -51,12 +55,14 @@ Defs(
comment: None, comment: None,
body_pattern: @15-23 RecordDestructure( body_pattern: @15-23 RecordDestructure(
[ [
@17-18 Identifier( @17-18 Identifier {
"x", ident: "x",
), suffixed: 0,
@20-21 Identifier( },
"y", @20-21 Identifier {
), ident: "y",
suffixed: 0,
},
], ],
), ),
body_expr: @26-49 Record( body_expr: @26-49 Record(

View file

@ -18,9 +18,10 @@ Defs(
header: TypeHeader { header: TypeHeader {
name: @0-6 "UserId", name: @0-6 "UserId",
vars: [ vars: [
@7-8 Identifier( @7-8 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
}, },
ann: @11-25 TagUnion { ann: @11-25 TagUnion {
@ -47,9 +48,10 @@ Defs(
"UserId", "UserId",
), ),
[ [
@7-8 Identifier( @7-8 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
), ),
ann_type: @11-25 TagUnion { ann_type: @11-25 TagUnion {
@ -73,9 +75,10 @@ Defs(
"UserId", "UserId",
), ),
[ [
@33-34 Identifier( @33-34 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
), ),
body_expr: @37-46 Apply( body_expr: @37-46 Apply(

View file

@ -18,12 +18,14 @@ Defs(
Annotation( Annotation(
@0-8 Tuple( @0-8 Tuple(
[ [
@2-3 Identifier( @2-3 Identifier {
"x", ident: "x",
), suffixed: 0,
@5-6 Identifier( },
"y", @5-6 Identifier {
), ident: "y",
suffixed: 0,
},
], ],
), ),
@11-14 Apply( @11-14 Apply(
@ -35,12 +37,14 @@ Defs(
AnnotatedBody { AnnotatedBody {
ann_pattern: @0-8 Tuple( ann_pattern: @0-8 Tuple(
[ [
@2-3 Identifier( @2-3 Identifier {
"x", ident: "x",
), suffixed: 0,
@5-6 Identifier( },
"y", @5-6 Identifier {
), ident: "y",
suffixed: 0,
},
], ],
), ),
ann_type: @11-14 Apply( ann_type: @11-14 Apply(
@ -51,12 +55,14 @@ Defs(
comment: None, comment: None,
body_pattern: @15-23 Tuple( body_pattern: @15-23 Tuple(
[ [
@17-18 Identifier( @17-18 Identifier {
"x", ident: "x",
), suffixed: 0,
@20-21 Identifier( },
"y", @20-21 Identifier {
), ident: "y",
suffixed: 0,
},
], ],
), ),
body_expr: @26-41 Tuple( body_expr: @26-41 Tuple(

View file

@ -17,9 +17,10 @@ SpaceBefore(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@107-108 Identifier( @107-108 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@111-112 Num( @111-112 Num(
"5", "5",
), ),

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Identifier( @0-1 Identifier {
"a", ident: "a",
), suffixed: 0,
},
@3-4 SpaceBefore( @3-4 SpaceBefore(
BoundVariable( BoundVariable(
"c", "c",

View file

@ -12,9 +12,10 @@ BinOps(
@5-12 Apply( @5-12 Apply(
@5-10 Closure( @5-10 Closure(
[ [
@6-7 Identifier( @6-7 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
@9-10 Var { @9-10 Var {
module_name: "", module_name: "",

View file

@ -13,9 +13,10 @@ BinOps(
@2-7 SpaceAfter( @2-7 SpaceAfter(
Closure( Closure(
[ [
@3-4 Identifier( @3-4 Identifier {
"s", ident: "s",
), suffixed: 0,
},
], ],
@6-7 Var { @6-7 Var {
module_name: "", module_name: "",

View file

@ -19,9 +19,10 @@ Defs {
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-3 Identifier( @0-3 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
@6-7 Num( @6-7 Num(
"1", "1",
), ),

View file

@ -20,9 +20,10 @@ Defs(
vars: [ vars: [
@3-4 SpaceAfter( @3-4 SpaceAfter(
SpaceBefore( SpaceBefore(
Identifier( Identifier {
"h", ident: "h",
), suffixed: 0,
},
[ [
LineComment( LineComment(
"", "",

View file

@ -17,9 +17,10 @@ Defs(
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 SpaceAfter( @0-1 SpaceAfter(
Identifier( Identifier {
"w", ident: "w",
), suffixed: 0,
},
[ [
LineComment( LineComment(
"", "",

View file

@ -17,9 +17,10 @@ Defs(
value_defs: [ value_defs: [
Body( Body(
@0-1 SpaceAfter( @0-1 SpaceAfter(
Identifier( Identifier {
"t", ident: "t",
), suffixed: 0,
},
[ [
LineComment( LineComment(
"", "",

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Identifier( @0-1 Identifier {
"a", ident: "a",
), suffixed: 0,
},
@2-3 BoundVariable( @2-3 BoundVariable(
"b", "b",
), ),

View file

@ -21,9 +21,10 @@ Defs(
"Email", "Email",
), ),
[ [
@6-9 Identifier( @6-9 Identifier {
"str", ident: "str",
), suffixed: 0,
},
], ],
), ),
@12-36 Apply( @12-36 Apply(

View file

@ -17,10 +17,11 @@ SpaceBefore(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@48-49 Identifier( @46-47 Identifier {
"x", ident: "x",
), suffixed: 0,
@52-53 Num( },
@50-51 Num(
"5", "5",
), ),
), ),

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-5 Identifier( @0-5 Identifier {
"table", ident: "table",
), suffixed: 0,
},
@8-44 Function( @8-44 Function(
[ [
@8-35 Record { @8-35 Record {
@ -54,9 +55,10 @@ Defs(
), ),
), ),
AnnotatedBody { AnnotatedBody {
ann_pattern: @0-5 Identifier( ann_pattern: @0-5 Identifier {
"table", ident: "table",
), suffixed: 0,
},
ann_type: @8-44 Function( ann_type: @8-44 Function(
[ [
@8-35 Record { @8-35 Record {
@ -91,16 +93,18 @@ Defs(
), ),
), ),
comment: None, comment: None,
body_pattern: @45-50 Identifier( body_pattern: @45-50 Identifier {
"table", ident: "table",
), suffixed: 0,
},
body_expr: @53-89 Closure( body_expr: @53-89 Closure(
[ [
@54-62 RecordDestructure( @54-62 RecordDestructure(
[ [
@55-61 Identifier( @55-61 Identifier {
"height", ident: "height",
), suffixed: 0,
},
], ],
), ),
], ],

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Identifier( @0-1 Identifier {
"f", ident: "f",
), suffixed: 0,
},
@4-20 Function( @4-20 Function(
[ [
@4-10 Tuple { @4-10 Tuple {
@ -53,9 +54,10 @@ Defs(
), ),
), ),
AnnotatedBody { AnnotatedBody {
ann_pattern: @0-1 Identifier( ann_pattern: @0-1 Identifier {
"f", ident: "f",
), suffixed: 0,
},
ann_type: @4-20 Function( ann_type: @4-20 Function(
[ [
@4-10 Tuple { @4-10 Tuple {
@ -89,14 +91,16 @@ Defs(
}, },
), ),
comment: None, comment: None,
body_pattern: @21-22 Identifier( body_pattern: @21-22 Identifier {
"f", ident: "f",
), suffixed: 0,
},
body_expr: @25-32 Closure( body_expr: @25-32 Closure(
[ [
@26-27 Identifier( @26-27 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
@31-32 Var { @31-32 Var {
module_name: "", module_name: "",

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Identifier( @0-1 Identifier {
"f", ident: "f",
), suffixed: 0,
},
@4-21 Function( @4-21 Function(
[ [
@4-7 Apply( @4-7 Apply(
@ -45,9 +46,10 @@ Defs(
), ),
), ),
AnnotatedBody { AnnotatedBody {
ann_pattern: @0-1 Identifier( ann_pattern: @0-1 Identifier {
"f", ident: "f",
), suffixed: 0,
},
ann_type: @4-21 Function( ann_type: @4-21 Function(
[ [
@4-7 Apply( @4-7 Apply(
@ -73,14 +75,16 @@ Defs(
}, },
), ),
comment: None, comment: None,
body_pattern: @22-23 Identifier( body_pattern: @22-23 Identifier {
"f", ident: "f",
), suffixed: 0,
},
body_expr: @26-42 Closure( body_expr: @26-42 Closure(
[ [
@27-28 Identifier( @27-28 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
@32-42 Tuple( @32-42 Tuple(
[ [

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-4 Identifier( @0-4 Identifier {
"iffy", ident: "iffy",
), suffixed: 0,
},
@5-6 Num( @5-6 Num(
"5", "5",
), ),

View file

@ -37,9 +37,10 @@ BinOps(
[ [
@37-54 Closure( @37-54 Closure(
[ [
@38-42 Identifier( @38-42 Identifier {
"byte", ident: "byte",
), suffixed: 0,
},
], ],
@46-54 BinOps( @46-54 BinOps(
[ [

View file

@ -1,8 +1,9 @@
Closure( Closure(
[ [
@1-2 Identifier( @1-2 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
@8-9 SpaceBefore( @8-9 SpaceBefore(
Num( Num(

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-6 Identifier( @0-6 Identifier {
"myList", ident: "myList",
), suffixed: 0,
},
@9-57 List( @9-57 List(
Collection { Collection {
items: [ items: [

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-6 Identifier( @0-6 Identifier {
"myList", ident: "myList",
), suffixed: 0,
},
@9-25 List( @9-25 List(
[ [
@15-16 SpaceBefore( @15-16 SpaceBefore(

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-6 Identifier( @0-6 Identifier {
"myList", ident: "myList",
), suffixed: 0,
},
@9-26 List( @9-26 List(
Collection { Collection {
items: [ items: [

View file

@ -73,18 +73,22 @@ When(
@60-72 SpaceBefore( @60-72 SpaceBefore(
List( List(
[ [
@61-62 Identifier( @61-62 Identifier {
"a", ident: "a",
), suffixed: 0,
@64-65 Identifier( },
"b", @64-65 Identifier {
), ident: "b",
@67-68 Identifier( suffixed: 0,
"c", },
), @67-68 Identifier {
@70-71 Identifier( ident: "c",
"d", suffixed: 0,
), },
@70-71 Identifier {
ident: "d",
suffixed: 0,
},
], ],
), ),
[ [
@ -102,12 +106,14 @@ When(
@81-91 SpaceBefore( @81-91 SpaceBefore(
List( List(
[ [
@82-83 Identifier( @82-83 Identifier {
"a", ident: "a",
), suffixed: 0,
@85-86 Identifier( },
"b", @85-86 Identifier {
), ident: "b",
suffixed: 0,
},
@88-90 ListRest( @88-90 ListRest(
None, None,
), ),
@ -131,12 +137,14 @@ When(
@101-103 ListRest( @101-103 ListRest(
None, None,
), ),
@105-106 Identifier( @105-106 Identifier {
"c", ident: "c",
), suffixed: 0,
@108-109 Identifier( },
"d", @108-109 Identifier {
), ident: "d",
suffixed: 0,
},
], ],
), ),
[ [
@ -170,9 +178,10 @@ When(
), ),
@131-134 List( @131-134 List(
[ [
@132-133 Identifier( @132-133 Identifier {
"a", ident: "a",
), suffixed: 0,
},
], ],
), ),
], ],
@ -207,9 +216,10 @@ When(
@156-158 List( @156-158 List(
[], [],
), ),
@160-161 Identifier( @160-161 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
), ),
], ],

View file

@ -17,9 +17,10 @@ SpaceBefore(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@113-114 Identifier( @113-114 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@117-118 Num( @117-118 Num(
"5", "5",
), ),

View file

@ -15,9 +15,10 @@ Defs {
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-4 Identifier( @0-4 Identifier {
"main", ident: "main",
), suffixed: 0,
},
@11-24 SpaceBefore( @11-24 SpaceBefore(
Defs( Defs(
Defs { Defs {
@ -37,9 +38,10 @@ Defs {
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@11-12 Identifier( @11-12 Identifier {
"i", ident: "i",
), suffixed: 0,
},
@15-17 Num( @15-17 Num(
"64", "64",
), ),

View file

@ -1,11 +1,13 @@
Backpassing( Backpassing(
[ [
@0-1 Identifier( @0-1 Identifier {
"x", ident: "x",
), suffixed: 0,
@3-4 Identifier( },
"y", @3-4 Identifier {
), ident: "y",
suffixed: 0,
},
], ],
@8-23 Apply( @8-23 Apply(
@8-17 Var { @8-17 Var {

View file

@ -15,18 +15,21 @@ Defs {
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-4 Identifier( @0-4 Identifier {
"main", ident: "main",
), suffixed: 0,
},
@12-50 SpaceBefore( @12-50 SpaceBefore(
Backpassing( Backpassing(
[ [
@12-16 Identifier( @12-16 Identifier {
"arg1", ident: "arg1",
), suffixed: 0,
@18-22 Identifier( },
"arg2", @18-22 Identifier {
), ident: "arg2",
suffixed: 0,
},
], ],
@26-30 Apply( @26-30 Apply(
@26-27 Var { @26-27 Var {

View file

@ -10,9 +10,10 @@ Backpassing(
), ),
], ],
), ),
@5-6 Identifier( @5-6 Identifier {
"r", ident: "r",
), suffixed: 0,
},
], ],
@10-11 Var { @10-11 Var {
module_name: "", module_name: "",

View file

@ -27,9 +27,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-1 Identifier( @0-1 Identifier {
"a", ident: "a",
), suffixed: 0,
},
@4-22 Str( @4-22 Str(
Line( Line(
[ [
@ -50,9 +51,10 @@ Defs(
), ),
), ),
Body( Body(
@23-24 Identifier( @23-24 Identifier {
"b", ident: "b",
), suffixed: 0,
},
@27-49 Str( @27-49 Str(
Block( Block(
[ [
@ -75,9 +77,10 @@ Defs(
), ),
), ),
Body( Body(
@50-51 Identifier( @50-51 Identifier {
"c", ident: "c",
), suffixed: 0,
},
@58-92 SpaceBefore( @58-92 SpaceBefore(
Str( Str(
Block( Block(

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Identifier( @0-1 Identifier {
"f", ident: "f",
), suffixed: 0,
},
@8-10 SpaceBefore( @8-10 SpaceBefore(
Record { Record {
fields: [], fields: [],

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Identifier( @0-1 Identifier {
"f", ident: "f",
), suffixed: 0,
},
@17-19 SpaceBefore( @17-19 SpaceBefore(
Record { Record {
fields: [], fields: [],

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-1 Identifier( @0-1 Identifier {
"a", ident: "a",
), suffixed: 0,
},
@2-9 Apply( @2-9 Apply(
@2-3 SpaceAfter( @2-3 SpaceAfter(
Tag( Tag(

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-4 Identifier( @0-4 Identifier {
"main", ident: "main",
), suffixed: 0,
},
@11-71 SpaceBefore( @11-71 SpaceBefore(
Defs( Defs(
Defs { Defs {
@ -38,14 +39,16 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@11-15 Identifier( @11-15 Identifier {
"task", ident: "task",
), suffixed: 0,
},
@18-62 Backpassing( @18-62 Backpassing(
[ [
@18-22 Identifier( @18-22 Identifier {
"file", ident: "file",
), suffixed: 0,
},
], ],
@43-46 SpaceBefore( @43-46 SpaceBefore(
Var { Var {

View file

@ -15,9 +15,10 @@ Defs {
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-4 Identifier( @0-4 Identifier {
"main", ident: "main",
), suffixed: 0,
},
@11-115 SpaceBefore( @11-115 SpaceBefore(
Defs( Defs(
Defs { Defs {
@ -37,9 +38,10 @@ Defs {
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@11-23 Identifier( @11-23 Identifier {
"wrappedNotEq", ident: "wrappedNotEq",
), suffixed: 0,
},
@26-38 Function( @26-38 Function(
[ [
@26-27 BoundVariable( @26-27 BoundVariable(
@ -57,9 +59,10 @@ Defs {
), ),
), ),
AnnotatedBody { AnnotatedBody {
ann_pattern: @11-23 Identifier( ann_pattern: @11-23 Identifier {
"wrappedNotEq", ident: "wrappedNotEq",
), suffixed: 0,
},
ann_type: @26-38 Function( ann_type: @26-38 Function(
[ [
@26-27 BoundVariable( @26-27 BoundVariable(
@ -76,17 +79,20 @@ Defs {
), ),
), ),
comment: None, comment: None,
body_pattern: @43-55 Identifier( body_pattern: @43-55 Identifier {
"wrappedNotEq", ident: "wrappedNotEq",
), suffixed: 0,
},
body_expr: @58-93 Closure( body_expr: @58-93 Closure(
[ [
@59-63 Identifier( @59-63 Identifier {
"num1", ident: "num1",
), suffixed: 0,
@65-69 Identifier( },
"num2", @65-69 Identifier {
), ident: "num2",
suffixed: 0,
},
], ],
@81-93 SpaceBefore( @81-93 SpaceBefore(
BinOps( BinOps(

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-1 Identifier( @0-1 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@2-7 Defs( @2-7 Defs(
Defs { Defs {
tags: [ tags: [
@ -37,9 +38,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@2-3 Identifier( @2-3 Identifier {
"a", ident: "a",
), suffixed: 0,
},
@4-5 BoundVariable( @4-5 BoundVariable(
"n", "n",
), ),

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-1 Identifier( @0-1 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@8-9 SpaceBefore( @8-9 SpaceBefore(
Num( Num(
"5", "5",

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-1 Identifier( @0-1 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@4-13 BinOps( @4-13 BinOps(
[ [
( (

View file

@ -100,9 +100,10 @@ Full {
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@199-203 Identifier( @199-203 Identifier {
"main", ident: "main",
), suffixed: 0,
},
@210-246 SpaceBefore( @210-246 SpaceBefore(
Apply( Apply(
@210-221 Var { @210-221 Var {

View file

@ -1,16 +1,18 @@
SpaceBefore( SpaceBefore(
Backpassing( Backpassing(
[ [
@18-19 Identifier( @18-19 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
@23-32 ParensAround( @23-32 ParensAround(
Closure( Closure(
[ [
@25-26 Identifier( @25-26 Identifier {
"y", ident: "y",
), suffixed: 0,
},
], ],
@30-31 Var { @30-31 Var {
module_name: "", module_name: "",

View file

@ -17,9 +17,10 @@ SpaceBefore(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@18-19 Identifier( @18-19 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@20-21 Num( @20-21 Num(
"5", "5",
), ),

View file

@ -17,9 +17,10 @@ SpaceBefore(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@18-19 Identifier( @18-19 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@22-23 Num( @22-23 Num(
"5", "5",
), ),

View file

@ -21,9 +21,10 @@ Defs(
"@Thunk", "@Thunk",
), ),
[ [
@7-9 Identifier( @7-9 Identifier {
"it", ident: "it",
), suffixed: 0,
},
], ],
), ),
@12-22 Apply( @12-22 Apply(

View file

@ -13,12 +13,14 @@ When(
"@Add", "@Add",
), ),
[ [
@17-18 Identifier( @17-18 Identifier {
"n", ident: "n",
), suffixed: 0,
@19-20 Identifier( },
"m", @19-20 Identifier {
), ident: "m",
suffixed: 0,
},
], ],
), ),
[ [

View file

@ -38,9 +38,10 @@ Defs(
], ],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Identifier( @0-1 Identifier {
"a", ident: "a",
), suffixed: 0,
},
@2-3 BoundVariable( @2-3 BoundVariable(
"e", "e",
), ),

View file

@ -17,9 +17,10 @@ Defs {
header: TypeHeader { header: TypeHeader {
name: @0-10 "Bookmark", name: @0-10 "Bookmark",
vars: [ vars: [
@9-10 Identifier( @9-10 Identifier {
"a", ident: "a",
), suffixed: 0,
},
], ],
}, },
typ: @14-53 Record { typ: @14-53 Record {

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-1 Identifier( @0-1 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@4-29 Apply( @4-29 Apply(
@4-7 Var { @4-7 Var {
module_name: "", module_name: "",

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-1 Identifier( @0-1 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@4-22 Apply( @4-22 Apply(
@4-7 Var { @4-7 Var {
module_name: "", module_name: "",

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-1 Identifier( @0-1 Identifier {
"a", ident: "a",
), suffixed: 0,
},
@4-17 List( @4-17 List(
[ [
@8-9 SpaceBefore( @8-9 SpaceBefore(

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-1 Identifier( @0-1 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@4-23 Apply( @4-23 Apply(
@4-7 Var { @4-7 Var {
module_name: "", module_name: "",

View file

@ -19,13 +19,15 @@ Defs(
name: @0-1 "U", name: @0-1 "U",
vars: [ vars: [
@2-5 Apply( @2-5 Apply(
@2-3 Identifier( @2-3 Identifier {
"b", ident: "b",
), suffixed: 0,
},
[ [
@4-5 Identifier( @4-5 Identifier {
"a", ident: "a",
), suffixed: 0,
},
], ],
), ),
], ],

View file

@ -17,9 +17,10 @@ Defs(
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Apply( @0-1 Apply(
@0-1 Identifier( @0-1 Identifier {
"i", ident: "i",
), suffixed: 0,
},
[ [
@5-6 SpaceBefore( @5-6 SpaceBefore(
Tag( Tag(

View file

@ -18,12 +18,14 @@ Defs(
header: TypeHeader { header: TypeHeader {
name: @0-4 "Blah", name: @0-4 "Blah",
vars: [ vars: [
@5-6 Identifier( @5-6 Identifier {
"a", ident: "a",
), suffixed: 0,
@7-8 Identifier( },
"b", @7-8 Identifier {
), ident: "b",
suffixed: 0,
},
], ],
}, },
ann: @11-26 Apply( ann: @11-26 Apply(

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-3 Identifier( @0-3 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
@6-33 As( @6-33 As(
@6-21 Apply( @6-21 Apply(
"Foo.Bar", "Foo.Bar",
@ -36,12 +37,14 @@ Defs(
TypeHeader { TypeHeader {
name: @25-29 "Blah", name: @25-29 "Blah",
vars: [ vars: [
@30-31 Identifier( @30-31 Identifier {
"a", ident: "a",
), suffixed: 0,
@32-33 Identifier( },
"b", @32-33 Identifier {
), ident: "b",
suffixed: 0,
},
], ],
}, },
), ),

View file

@ -10,9 +10,10 @@ When(
@19-38 SpaceBefore( @19-38 SpaceBefore(
List( List(
[ [
@20-25 Identifier( @20-25 Identifier {
"first", ident: "first",
), suffixed: 0,
},
@27-37 ListRest( @27-37 ListRest(
Some( Some(
( (

View file

@ -39,9 +39,10 @@ When(
"Del", "Del",
), ),
[ [
@42-44 Identifier( @42-44 Identifier {
"ry", ident: "ry",
), suffixed: 0,
},
], ],
), ),
@47-48 Underscore( @47-48 Underscore(

View file

@ -25,12 +25,14 @@ SpaceBefore(
Body( Body(
@18-26 RecordDestructure( @18-26 RecordDestructure(
[ [
@20-21 Identifier( @20-21 Identifier {
"x", ident: "x",
), suffixed: 0,
@23-25 Identifier( },
"y", @23-25 Identifier {
), ident: "y",
suffixed: 0,
},
], ],
), ),
@29-30 Num( @29-30 Num(
@ -38,9 +40,10 @@ SpaceBefore(
), ),
), ),
Body( Body(
@31-32 Identifier( @31-32 Identifier {
"y", ident: "y",
), suffixed: 0,
},
@35-36 Num( @35-36 Num(
"6", "6",
), ),

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Identifier( @0-1 Identifier {
"f", ident: "f",
), suffixed: 0,
},
@8-122 SpaceBefore( @8-122 SpaceBefore(
Record { Record {
fields: [ fields: [

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Identifier( @0-1 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@4-77 Record { @4-77 Record {
fields: [ fields: [
@6-24 RequiredValue( @6-24 RequiredValue(

View file

@ -1,8 +1,9 @@
Closure( Closure(
[ [
@1-2 Identifier( @1-2 Identifier {
"a", ident: "a",
), suffixed: 0,
},
], ],
@6-8 Num( @6-8 Num(
"42", "42",

View file

@ -93,9 +93,10 @@ Full {
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@98-102 Identifier( @98-102 Identifier {
"main", ident: "main",
), suffixed: 0,
},
@105-124 Apply( @105-124 Apply(
@105-116 Var { @105-116 Var {
module_name: "Stdout", module_name: "Stdout",

View file

@ -37,17 +37,19 @@ Defs {
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@12-15 Identifier( @12-15 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
@18-19 Num( @18-19 Num(
"1", "1",
), ),
), ),
Body( Body(
@33-36 Identifier( @33-36 Identifier {
"bar", ident: "bar",
), suffixed: 0,
},
@39-43 Str( @39-43 Str(
PlainLine( PlainLine(
"hi", "hi",
@ -55,9 +57,10 @@ Defs {
), ),
), ),
Body( Body(
@44-47 Identifier( @44-47 Identifier {
"baz", ident: "baz",
), suffixed: 0,
},
@50-57 Str( @50-57 Str(
PlainLine( PlainLine(
"stuff", "stuff",

View file

@ -64,9 +64,10 @@ Defs {
@120-131 SpaceBefore( @120-131 SpaceBefore(
Closure( Closure(
[ [
@121-122 Identifier( @121-122 Identifier {
"a", ident: "a",
), suffixed: 0,
},
], ],
@126-131 BinOps( @126-131 BinOps(
[ [

View file

@ -8,7 +8,8 @@ app "desugar-bang"
provides [main] to cli provides [main] to cli
main = main =
Stdout.line! "Foo" Stdout.line!
"Foo"
"Bar" "Bar"
|> Stdout.line |> Stdout.line

View file

@ -98,7 +98,7 @@ Full {
Index(2147483648), Index(2147483648),
], ],
regions: [ regions: [
@155-184, @155-215,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 2), Slice(start = 0, length = 2),
@ -113,59 +113,41 @@ Full {
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@155-159 Identifier( @155-159 Identifier {
"main", ident: "main",
), suffixed: 0,
@155-184 Defs( },
Defs { @166-215 SpaceBefore(
tags: [ BinOps(
Index(2147483648), [
], (
regions: [ @166-195 SpaceAfter(
@155-184, Apply(
], @166-178 Var {
space_before: [
Slice(start = 0, length = 0),
],
space_after: [
Slice(start = 0, length = 0),
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@155-184 RecordDestructure(
[],
),
@155-184 Apply(
@166-178 Suffixed(
Var {
module_name: "Stdout", module_name: "Stdout",
ident: "line", ident: "line",
suffixed: 1,
}, },
),
[ [
@179-184 Str( @179-184 Str(
PlainLine( PlainLine(
"Foo", "Foo",
), ),
), ),
], @190-195 SpaceBefore(
Space,
),
),
],
},
@190-215 SpaceBefore(
BinOps(
[
(
@190-195 SpaceAfter(
Str( Str(
PlainLine( PlainLine(
"Bar", "Bar",
), ),
), ),
[
Newline,
Newline,
],
),
],
Space,
),
[ [
Newline, Newline,
], ],
@ -176,15 +158,14 @@ Full {
@204-215 Var { @204-215 Var {
module_name: "Stdout", module_name: "Stdout",
ident: "line", ident: "line",
suffixed: 0,
}, },
), ),
[ [
Newline, Newline,
Newline,
], ],
), ),
), ),
),
], ],
}, },
} }

View file

@ -95,9 +95,10 @@ Full {
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@88-92 Identifier( @88-92 Identifier {
"main", ident: "main",
), suffixed: 0,
},
@100-202 SpaceBefore( @100-202 SpaceBefore(
BinOps( BinOps(
[ [

View file

@ -1,14 +1,17 @@
Closure( Closure(
[ [
@1-2 Identifier( @1-2 Identifier {
"a", ident: "a",
), suffixed: 0,
@4-5 Identifier( },
"b", @4-5 Identifier {
), ident: "b",
@7-8 Identifier( suffixed: 0,
"c", },
), @7-8 Identifier {
ident: "c",
suffixed: 0,
},
], ],
@12-14 Num( @12-14 Num(
"42", "42",

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-3 Identifier( @0-3 Identifier {
"abc", ident: "abc",
), suffixed: 0,
},
@6-15 Tuple( @6-15 Tuple(
[ [
@7-8 Num( @7-8 Num(

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Identifier( @0-1 Identifier {
"f", ident: "f",
), suffixed: 0,
},
@3-27 Function( @3-27 Function(
[ [
@3-13 Tuple { @3-13 Tuple {
@ -55,9 +56,10 @@ Defs(
), ),
), ),
AnnotatedBody { AnnotatedBody {
ann_pattern: @0-1 Identifier( ann_pattern: @0-1 Identifier {
"f", ident: "f",
), suffixed: 0,
},
ann_type: @3-27 Function( ann_type: @3-27 Function(
[ [
@3-13 Tuple { @3-13 Tuple {
@ -93,14 +95,16 @@ Defs(
}, },
), ),
comment: None, comment: None,
body_pattern: @28-29 Identifier( body_pattern: @28-29 Identifier {
"f", ident: "f",
), suffixed: 0,
},
body_expr: @32-39 Closure( body_expr: @32-39 Closure(
[ [
@33-34 Identifier( @33-34 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
@38-39 Var { @38-39 Var {
module_name: "", module_name: "",

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Identifier( @0-1 Identifier {
"f", ident: "f",
), suffixed: 0,
},
@3-29 Function( @3-29 Function(
[ [
@3-14 Tuple { @3-14 Tuple {
@ -63,9 +64,10 @@ Defs(
), ),
), ),
AnnotatedBody { AnnotatedBody {
ann_pattern: @0-1 Identifier( ann_pattern: @0-1 Identifier {
"f", ident: "f",
), suffixed: 0,
},
ann_type: @3-29 Function( ann_type: @3-29 Function(
[ [
@3-14 Tuple { @3-14 Tuple {
@ -109,14 +111,16 @@ Defs(
}, },
), ),
comment: None, comment: None,
body_pattern: @30-31 Identifier( body_pattern: @30-31 Identifier {
"f", ident: "f",
), suffixed: 0,
},
body_expr: @34-41 Closure( body_expr: @34-41 Closure(
[ [
@35-36 Identifier( @35-36 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
@40-41 Var { @40-41 Var {
module_name: "", module_name: "",

View file

@ -1,11 +1,13 @@
Closure( Closure(
[ [
@1-2 Identifier( @1-2 Identifier {
"a", ident: "a",
), suffixed: 0,
@4-5 Identifier( },
"b", @4-5 Identifier {
), ident: "b",
suffixed: 0,
},
], ],
@9-11 Num( @9-11 Num(
"42", "42",

View file

@ -1,16 +1,18 @@
SpaceBefore( SpaceBefore(
Backpassing( Backpassing(
[ [
@18-19 Identifier( @18-19 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
@23-32 ParensAround( @23-32 ParensAround(
Closure( Closure(
[ [
@25-26 Identifier( @25-26 Identifier {
"y", ident: "y",
), suffixed: 0,
},
], ],
@30-31 Var { @30-31 Var {
module_name: "", module_name: "",
@ -22,9 +24,10 @@ SpaceBefore(
@33-43 SpaceBefore( @33-43 SpaceBefore(
Backpassing( Backpassing(
[ [
@33-34 Identifier( @33-34 Identifier {
"z", ident: "z",
), suffixed: 0,
},
], ],
@38-40 Record( @38-40 Record(
[], [],

View file

@ -23,17 +23,19 @@ SpaceBefore(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@18-19 Identifier( @18-19 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@22-23 Num( @22-23 Num(
"5", "5",
), ),
), ),
Body( Body(
@24-25 Identifier( @24-25 Identifier {
"y", ident: "y",
), suffixed: 0,
},
@28-29 Num( @28-29 Num(
"6", "6",
), ),

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-7 Identifier( @0-7 Identifier {
"doStuff", ident: "doStuff",
), suffixed: 0,
},
@10-30 Function( @10-30 Function(
[ [
@10-16 Apply( @10-16 Apply(

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-3 Identifier( @0-3 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
@6-9 Apply( @6-9 Apply(
"", "",
"Int", "Int",
@ -26,18 +27,20 @@ Defs(
), ),
), ),
AnnotatedBody { AnnotatedBody {
ann_pattern: @0-3 Identifier( ann_pattern: @0-3 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
ann_type: @6-9 Apply( ann_type: @6-9 Apply(
"", "",
"Int", "Int",
[], [],
), ),
comment: None, comment: None,
body_pattern: @10-13 Identifier( body_pattern: @10-13 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
body_expr: @16-17 Num( body_expr: @16-17 Num(
"4", "4",
), ),

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-3 Identifier( @0-3 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
@6-24 Function( @6-24 Function(
[ [
@6-9 Apply( @6-9 Apply(
@ -40,9 +41,10 @@ Defs(
), ),
), ),
AnnotatedBody { AnnotatedBody {
ann_pattern: @0-3 Identifier( ann_pattern: @0-3 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
ann_type: @6-24 Function( ann_type: @6-24 Function(
[ [
@6-9 Apply( @6-9 Apply(
@ -63,14 +65,16 @@ Defs(
), ),
), ),
comment: None, comment: None,
body_pattern: @25-28 Identifier( body_pattern: @25-28 Identifier {
"foo", ident: "foo",
), suffixed: 0,
},
body_expr: @31-42 Closure( body_expr: @31-42 Closure(
[ [
@32-33 Identifier( @32-33 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@35-36 Underscore( @35-36 Underscore(
"", "",
), ),

View file

@ -8,9 +8,10 @@ SpaceBefore(
@23-32 ParensAround( @23-32 ParensAround(
Closure( Closure(
[ [
@25-26 Identifier( @25-26 Identifier {
"y", ident: "y",
), suffixed: 0,
},
], ],
@30-31 Var { @30-31 Var {
module_name: "", module_name: "",

View file

@ -42,9 +42,10 @@ Defs(
"Pair", "Pair",
), ),
[ [
@5-6 Identifier( @5-6 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@7-8 Underscore( @7-8 Underscore(
"", "",
), ),
@ -74,9 +75,10 @@ Defs(
@25-26 Underscore( @25-26 Underscore(
"", "",
), ),
@27-28 Identifier( @27-28 Identifier {
"y", ident: "y",
), suffixed: 0,
},
], ],
), ),
@31-39 Apply( @31-39 Apply(
@ -153,9 +155,10 @@ Defs(
"Pair", "Pair",
), ),
[ [
@84-85 Identifier( @84-85 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@86-87 Underscore( @86-87 Underscore(
"", "",
), ),
@ -169,9 +172,10 @@ Defs(
@95-96 Underscore( @95-96 Underscore(
"", "",
), ),
@97-98 Identifier( @97-98 Identifier {
"y", ident: "y",
), suffixed: 0,
},
], ],
), ),
], ],

View file

@ -32,9 +32,10 @@ Defs(
], ],
value_defs: [ value_defs: [
Annotation( Annotation(
@0-1 Identifier( @0-1 Identifier {
"a", ident: "a",
), suffixed: 0,
},
@2-3 Apply( @2-3 Apply(
"", "",
"F", "F",

View file

@ -16,9 +16,10 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-1 Identifier( @0-1 Identifier {
"x", ident: "x",
), suffixed: 0,
},
@4-25 When( @4-25 When(
@9-10 Var { @9-10 Var {
module_name: "", module_name: "",

View file

@ -16,14 +16,16 @@ Defs(
type_defs: [], type_defs: [],
value_defs: [ value_defs: [
Body( Body(
@0-4 Identifier( @0-4 Identifier {
"func", ident: "func",
), suffixed: 0,
},
@7-43 Closure( @7-43 Closure(
[ [
@8-9 Identifier( @8-9 Identifier {
"x", ident: "x",
), suffixed: 0,
},
], ],
@13-43 When( @13-43 When(
@18-19 Var { @18-19 Var {

Some files were not shown because too many files have changed in this diff Show more