mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-01 21:40:58 +00:00
add suffixed to Identifer and QualifiedIdentifier
This commit is contained in:
parent
0a3b9c34b3
commit
3c3e523b45
115 changed files with 1587 additions and 1085 deletions
|
|
@ -748,9 +748,10 @@ fn can_annotation_help(
|
|||
|
||||
for loc_var in *loc_vars {
|
||||
let var = match loc_var.value {
|
||||
Pattern::Identifier(name) if name.chars().next().unwrap().is_lowercase() => {
|
||||
name
|
||||
}
|
||||
Pattern::Identifier {
|
||||
ident: name,
|
||||
suffixed: _,
|
||||
} if name.chars().next().unwrap().is_lowercase() => name,
|
||||
_ => unreachable!("I thought this was validated during parsing"),
|
||||
};
|
||||
let var_name = Lowercase::from(var);
|
||||
|
|
|
|||
|
|
@ -547,7 +547,11 @@ fn canonicalize_claimed_ability_impl<'a>(
|
|||
}
|
||||
AssignedField::RequiredValue(label, _spaces, 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() {
|
||||
ident
|
||||
} else {
|
||||
|
|
@ -2570,9 +2574,10 @@ fn to_pending_alias_or_opaque<'a>(
|
|||
|
||||
for loc_var in vars.iter() {
|
||||
match loc_var.value {
|
||||
ast::Pattern::Identifier(name)
|
||||
if name.chars().next().unwrap().is_lowercase() =>
|
||||
{
|
||||
ast::Pattern::Identifier {
|
||||
ident: name,
|
||||
suffixed: _,
|
||||
} if name.chars().next().unwrap().is_lowercase() => {
|
||||
let lowercase = Lowercase::from(name);
|
||||
can_rigids.push(Loc {
|
||||
value: lowercase,
|
||||
|
|
@ -2874,6 +2879,8 @@ fn to_pending_value_def<'a>(
|
|||
condition,
|
||||
preceding_comment: *preceding_comment,
|
||||
}),
|
||||
|
||||
Stmt(_) => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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_apply_pattern = ast::Pattern::Apply(
|
||||
opaque_ref,
|
||||
&*env
|
||||
.arena
|
||||
.alloc([Loc::at(DERIVED_REGION, ast::Pattern::Identifier(payload))]),
|
||||
&*env.arena.alloc([Loc::at(
|
||||
DERIVED_REGION,
|
||||
ast::Pattern::Identifier {
|
||||
ident: payload,
|
||||
suffixed: 0,
|
||||
},
|
||||
)]),
|
||||
);
|
||||
|
||||
// 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 {
|
||||
module_name: "Encode",
|
||||
ident: "toEncoder",
|
||||
suffixed: 0,
|
||||
}),
|
||||
&*env.arena.alloc([&*alloc_expr(ast::Expr::Var {
|
||||
module_name: "",
|
||||
ident: payload,
|
||||
suffixed: 0,
|
||||
})]),
|
||||
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 {
|
||||
module_name: "Decode",
|
||||
ident: "decodeWith",
|
||||
suffixed: 0,
|
||||
}),
|
||||
env.arena.alloc([
|
||||
&*alloc_expr(ast::Expr::Var {
|
||||
module_name: "",
|
||||
ident: bytes,
|
||||
suffixed: 0,
|
||||
}),
|
||||
alloc_expr(ast::Expr::Var {
|
||||
module_name: "Decode",
|
||||
ident: "decoder",
|
||||
suffixed: 0,
|
||||
}),
|
||||
alloc_expr(ast::Expr::Var {
|
||||
module_name: "",
|
||||
ident: fmt,
|
||||
suffixed: 0,
|
||||
}),
|
||||
]),
|
||||
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 {
|
||||
module_name: "Decode",
|
||||
ident: "mapResult",
|
||||
suffixed: 0,
|
||||
}),
|
||||
env.arena.alloc([
|
||||
&*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
|
||||
let custom_closure = ast::Expr::Closure(
|
||||
env.arena.alloc([
|
||||
Loc::at(DERIVED_REGION, ast::Pattern::Identifier(bytes)),
|
||||
Loc::at(DERIVED_REGION, ast::Pattern::Identifier(fmt)),
|
||||
Loc::at(
|
||||
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),
|
||||
);
|
||||
|
|
@ -107,6 +130,7 @@ fn decoder<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
|
|||
alloc_expr(ast::Expr::Var {
|
||||
module_name: "Decode",
|
||||
ident: "custom",
|
||||
suffixed: 0,
|
||||
}),
|
||||
env.arena.alloc([&*alloc_expr(custom_closure)]),
|
||||
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_apply_pattern = ast::Pattern::Apply(
|
||||
opaque_ref,
|
||||
&*env
|
||||
.arena
|
||||
.alloc([Loc::at(DERIVED_REGION, ast::Pattern::Identifier(payload))]),
|
||||
&*env.arena.alloc([Loc::at(
|
||||
DERIVED_REGION,
|
||||
ast::Pattern::Identifier {
|
||||
ident: payload,
|
||||
suffixed: 0,
|
||||
},
|
||||
)]),
|
||||
);
|
||||
|
||||
// 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 {
|
||||
module_name: "Hash",
|
||||
ident: "hash",
|
||||
suffixed: 0,
|
||||
}),
|
||||
&*env.arena.alloc([
|
||||
&*alloc_expr(ast::Expr::Var {
|
||||
module_name: "",
|
||||
ident: hasher,
|
||||
suffixed: 0,
|
||||
}),
|
||||
&*alloc_expr(ast::Expr::Var {
|
||||
module_name: "",
|
||||
ident: payload,
|
||||
suffixed: 0,
|
||||
}),
|
||||
]),
|
||||
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
|
||||
ast::Expr::Closure(
|
||||
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),
|
||||
]),
|
||||
call_member,
|
||||
|
|
@ -172,16 +209,24 @@ fn is_eq<'a>(env: &mut Env<'a>, at_opaque: &'a str) -> ast::Expr<'a> {
|
|||
// \@Opaq payload1
|
||||
let opaque1 = ast::Pattern::Apply(
|
||||
opaque_ref,
|
||||
&*env
|
||||
.arena
|
||||
.alloc([Loc::at(DERIVED_REGION, ast::Pattern::Identifier(payload1))]),
|
||||
&*env.arena.alloc([Loc::at(
|
||||
DERIVED_REGION,
|
||||
ast::Pattern::Identifier {
|
||||
ident: payload1,
|
||||
suffixed: 0,
|
||||
},
|
||||
)]),
|
||||
);
|
||||
// \@Opaq payload2
|
||||
let opaque2 = ast::Pattern::Apply(
|
||||
opaque_ref,
|
||||
&*env
|
||||
.arena
|
||||
.alloc([Loc::at(DERIVED_REGION, ast::Pattern::Identifier(payload2))]),
|
||||
&*env.arena.alloc([Loc::at(
|
||||
DERIVED_REGION,
|
||||
ast::Pattern::Identifier {
|
||||
ident: payload2,
|
||||
suffixed: 0,
|
||||
},
|
||||
)]),
|
||||
);
|
||||
|
||||
// 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 {
|
||||
module_name: "Bool",
|
||||
ident: "isEq",
|
||||
suffixed: 0,
|
||||
}),
|
||||
&*env.arena.alloc([
|
||||
&*alloc_expr(ast::Expr::Var {
|
||||
module_name: "",
|
||||
ident: payload1,
|
||||
suffixed: 0,
|
||||
}),
|
||||
&*alloc_expr(ast::Expr::Var {
|
||||
module_name: "",
|
||||
ident: payload2,
|
||||
suffixed: 0,
|
||||
}),
|
||||
]),
|
||||
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_apply_pattern = ast::Pattern::Apply(
|
||||
opaque_ref,
|
||||
&*env
|
||||
.arena
|
||||
.alloc([Loc::at(DERIVED_REGION, ast::Pattern::Identifier(payload))]),
|
||||
&*env.arena.alloc([Loc::at(
|
||||
DERIVED_REGION,
|
||||
ast::Pattern::Identifier {
|
||||
ident: payload,
|
||||
suffixed: 0,
|
||||
},
|
||||
)]),
|
||||
);
|
||||
|
||||
// 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 {
|
||||
module_name: "Inspect",
|
||||
ident: "toInspector",
|
||||
suffixed: 0,
|
||||
}),
|
||||
&*env.arena.alloc([&*alloc_expr(ast::Expr::Var {
|
||||
module_name: "",
|
||||
ident: payload,
|
||||
suffixed: 0,
|
||||
})]),
|
||||
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 {
|
||||
module_name: "Inspect",
|
||||
ident: "tag",
|
||||
suffixed: 0,
|
||||
}),
|
||||
&*env.arena.alloc([&*opaque_name, &*to_inspector_list]),
|
||||
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 {
|
||||
module_name: "Inspect",
|
||||
ident: "apply",
|
||||
suffixed: 0,
|
||||
}),
|
||||
&*env.arena.alloc([
|
||||
&*opaque_inspector,
|
||||
&*alloc_expr(ast::Expr::Var {
|
||||
module_name: "",
|
||||
ident: fmt,
|
||||
suffixed: 0,
|
||||
}),
|
||||
]),
|
||||
roc_module::called_via::CalledVia::Space,
|
||||
));
|
||||
|
||||
let custom_closure = alloc_expr(ast::Expr::Closure(
|
||||
env.arena
|
||||
.alloc([Loc::at(DERIVED_REGION, ast::Pattern::Identifier(fmt))]),
|
||||
env.arena.alloc([Loc::at(
|
||||
DERIVED_REGION,
|
||||
ast::Pattern::Identifier {
|
||||
ident: fmt,
|
||||
suffixed: 0,
|
||||
},
|
||||
)]),
|
||||
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 {
|
||||
module_name: "Inspect",
|
||||
ident: "custom",
|
||||
suffixed: 0,
|
||||
}),
|
||||
env.arena.alloc([&*custom_closure]),
|
||||
CalledVia::Space,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,11 @@ fn new_op_call_expr<'a>(
|
|||
let args = arena.alloc([left, right]);
|
||||
|
||||
let loc_expr = arena.alloc(Loc {
|
||||
value: Expr::Var { module_name, ident },
|
||||
value: Expr::Var {
|
||||
module_name,
|
||||
ident,
|
||||
suffixed: 0,
|
||||
},
|
||||
region: loc_op.region,
|
||||
});
|
||||
|
||||
|
|
@ -128,6 +132,8 @@ fn desugar_value_def<'a>(
|
|||
preceding_comment: *preceding_comment,
|
||||
}
|
||||
}
|
||||
|
||||
Stmt(_) => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -188,6 +194,7 @@ fn desugar_defs_node_suffixed<'a>(
|
|||
value: Var {
|
||||
module_name: ModuleName::TASK,
|
||||
ident: "await",
|
||||
suffixed: 0, // TODO this isn't right
|
||||
},
|
||||
}),
|
||||
arena.alloc(task_await_apply_args),
|
||||
|
|
@ -246,6 +253,7 @@ fn desugar_defs_node_suffixed<'a>(
|
|||
value: Var {
|
||||
module_name: ModuleName::TASK,
|
||||
ident: "await",
|
||||
suffixed: 0, // TODO this isn't right
|
||||
},
|
||||
}),
|
||||
arena.alloc(task_await_apply_args),
|
||||
|
|
@ -307,6 +315,7 @@ fn desugar_defs_node_suffixed<'a>(
|
|||
value: Var {
|
||||
module_name: ModuleName::TASK,
|
||||
ident: "await",
|
||||
suffixed: 0, // TODO this isn't right
|
||||
},
|
||||
}),
|
||||
arena.alloc(task_await_apply_args),
|
||||
|
|
@ -337,28 +346,29 @@ fn unwrap_suffixed_def_and_pattern<'a>(
|
|||
roc_parse::ast::Expr<'a>,
|
||||
&'a Loc<roc_parse::ast::Pattern<'a>>,
|
||||
) {
|
||||
match value_def {
|
||||
ValueDef::Body(pattern, suffixed_expression) => match suffixed_expression.value {
|
||||
// The Suffixed has arguments applied e.g. `Stdout.line! "Hello World"`
|
||||
Apply(sub_loc, suffixed_args, called_via) => match sub_loc.value {
|
||||
Suffixed(sub_expr) => (
|
||||
Apply(
|
||||
arena.alloc(Loc::at(region, *sub_expr)),
|
||||
suffixed_args,
|
||||
called_via,
|
||||
),
|
||||
pattern,
|
||||
),
|
||||
_ => 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),
|
||||
_ => {
|
||||
unreachable!("should have a suffixed Apply inside Body def")
|
||||
}
|
||||
},
|
||||
_ => unreachable!("should have a suffixed Body def"),
|
||||
}
|
||||
todo!()
|
||||
// match value_def {
|
||||
// ValueDef::Body(pattern, suffixed_expression) => match suffixed_expression.value {
|
||||
// // The Suffixed has arguments applied e.g. `Stdout.line! "Hello World"`
|
||||
// Apply(sub_loc, suffixed_args, called_via) => match sub_loc.value {
|
||||
// Suffixed(sub_expr) => (
|
||||
// Apply(
|
||||
// arena.alloc(Loc::at(region, *sub_expr)),
|
||||
// suffixed_args,
|
||||
// called_via,
|
||||
// ),
|
||||
// pattern,
|
||||
// ),
|
||||
// _ => 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),
|
||||
// _ => {
|
||||
// unreachable!("should have a suffixed Apply inside Body def")
|
||||
// }
|
||||
// },
|
||||
// _ => unreachable!("should have a suffixed Body def"),
|
||||
// }
|
||||
}
|
||||
|
||||
/// Reorder the expression tree based on operator precedence and associativity rules,
|
||||
|
|
@ -699,10 +709,12 @@ pub fn desugar_expr<'a>(
|
|||
Negate => Var {
|
||||
module_name: ModuleName::NUM,
|
||||
ident: "neg",
|
||||
suffixed: 0,
|
||||
},
|
||||
Not => Var {
|
||||
module_name: ModuleName::BOOL,
|
||||
ident: "not",
|
||||
suffixed: 0,
|
||||
},
|
||||
};
|
||||
let loc_fn_var = arena.alloc(Loc { region, value });
|
||||
|
|
@ -800,6 +812,7 @@ pub fn desugar_expr<'a>(
|
|||
let inspect_fn = Var {
|
||||
module_name: ModuleName::INSPECT,
|
||||
ident: "toStr",
|
||||
suffixed: 0,
|
||||
};
|
||||
let loc_inspect_fn_var = arena.alloc(Loc {
|
||||
value: inspect_fn,
|
||||
|
|
@ -840,30 +853,30 @@ pub fn desugar_expr<'a>(
|
|||
})
|
||||
}
|
||||
LowLevelDbg(_, _, _) => unreachable!("Only exists after desugaring"),
|
||||
Suffixed(expr) => {
|
||||
// Rewrite `Suffixed(BinOps([args...], Var(...)))` to `BinOps([args...], Suffixed(Var(...)))`
|
||||
// This is to handle cases like e.g. `"Hello" |> line!`
|
||||
if let BinOps(args, sub_expr) = expr {
|
||||
return desugar_expr(
|
||||
arena,
|
||||
arena.alloc(Loc::at(
|
||||
loc_expr.region,
|
||||
BinOps(
|
||||
args,
|
||||
arena.alloc(Loc::at(sub_expr.region, Suffixed(&sub_expr.value))),
|
||||
),
|
||||
)),
|
||||
src,
|
||||
line_info,
|
||||
module_path,
|
||||
);
|
||||
}
|
||||
// Suffixed(expr) => {
|
||||
// // Rewrite `Suffixed(BinOps([args...], Var(...)))` to `BinOps([args...], Suffixed(Var(...)))`
|
||||
// // This is to handle cases like e.g. `"Hello" |> line!`
|
||||
// if let BinOps(args, sub_expr) = expr {
|
||||
// return desugar_expr(
|
||||
// arena,
|
||||
// arena.alloc(Loc::at(
|
||||
// loc_expr.region,
|
||||
// BinOps(
|
||||
// args,
|
||||
// arena.alloc(Loc::at(sub_expr.region, Suffixed(&sub_expr.value))),
|
||||
// ),
|
||||
// )),
|
||||
// src,
|
||||
// line_info,
|
||||
// module_path,
|
||||
// );
|
||||
// }
|
||||
|
||||
// Suffixed are also desugared in Defs
|
||||
// Any nodes that don't get desugared will be caught by canonicalize_expr
|
||||
// and we can handle those cases as required
|
||||
loc_expr
|
||||
}
|
||||
// // Suffixed are also desugared in Defs
|
||||
// // Any nodes that don't get desugared will be caught by canonicalize_expr
|
||||
// // and we can handle those cases as required
|
||||
// loc_expr
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -949,6 +962,7 @@ fn desugar_field<'a>(
|
|||
value: Var {
|
||||
module_name: "",
|
||||
ident: loc_str.value,
|
||||
suffixed: 0,
|
||||
},
|
||||
region: loc_str.region,
|
||||
};
|
||||
|
|
@ -1009,7 +1023,7 @@ fn desugar_pattern<'a>(
|
|||
use roc_parse::ast::Pattern::*;
|
||||
|
||||
match pattern {
|
||||
Identifier(_)
|
||||
Identifier { .. }
|
||||
| Tag(_)
|
||||
| OpaqueRef(_)
|
||||
| NumLiteral(_)
|
||||
|
|
@ -1093,8 +1107,6 @@ fn desugar_pattern<'a>(
|
|||
SpaceAfter(sub_pattern, _spaces) => {
|
||||
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 {
|
||||
module_name: "",
|
||||
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() {
|
||||
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 {
|
||||
value: ident,
|
||||
|
|
|
|||
|
|
@ -1016,9 +1016,11 @@ pub fn canonicalize_expr<'a>(
|
|||
(expr, output)
|
||||
}
|
||||
}
|
||||
ast::Expr::Var { module_name, ident } => {
|
||||
canonicalize_var_lookup(env, var_store, scope, module_name, ident, region)
|
||||
}
|
||||
ast::Expr::Var {
|
||||
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) => {
|
||||
// we parse underscores, but they are not valid expression syntax
|
||||
|
||||
|
|
@ -1441,12 +1443,6 @@ pub fn canonicalize_expr<'a>(
|
|||
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.
|
||||
|
|
@ -2512,7 +2508,6 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
|
|||
ast::RecordBuilderField::SpaceBefore(_, _)
|
||||
| ast::RecordBuilderField::SpaceAfter(_, _) => false,
|
||||
}),
|
||||
ast::Expr::Suffixed(_) => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use crate::num::{
|
|||
ParsedNumResult,
|
||||
};
|
||||
use crate::scope::{PendingAbilitiesInScope, Scope};
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_exhaustive::ListArity;
|
||||
use roc_module::ident::{Ident, Lowercase, TagName};
|
||||
use roc_module::symbol::Symbol;
|
||||
|
|
@ -266,7 +265,11 @@ pub fn canonicalize_def_header_pattern<'a>(
|
|||
|
||||
match pattern {
|
||||
// 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(
|
||||
pending_abilities_in_scope,
|
||||
(*name).into(),
|
||||
|
|
@ -374,12 +377,14 @@ pub fn canonicalize_pattern<'a>(
|
|||
use PatternType::*;
|
||||
|
||||
let can_pattern = match pattern {
|
||||
Identifier(name) => {
|
||||
match canonicalize_pattern_symbol(env, scope, output, region, permit_shadows, name) {
|
||||
Ok(symbol) => Pattern::Identifier(symbol),
|
||||
Err(pattern) => pattern,
|
||||
}
|
||||
}
|
||||
// TODO do we need to use suffixed here?
|
||||
Identifier {
|
||||
ident: name,
|
||||
suffixed: _,
|
||||
} => match canonicalize_pattern_symbol(env, scope, output, region, permit_shadows, name) {
|
||||
Ok(symbol) => Pattern::Identifier(symbol),
|
||||
Err(pattern) => pattern,
|
||||
},
|
||||
Underscore(name) => {
|
||||
// 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.
|
||||
|
|
@ -629,7 +634,11 @@ pub fn canonicalize_pattern<'a>(
|
|||
|
||||
for loc_pattern in patterns.iter() {
|
||||
match loc_pattern.value {
|
||||
Identifier(label) => {
|
||||
// TODO should we use suffixed here?
|
||||
Identifier {
|
||||
ident: label,
|
||||
suffixed: _,
|
||||
} => {
|
||||
match scope.introduce(label.into(), region) {
|
||||
Ok(symbol) => {
|
||||
output.references.insert_bound(symbol);
|
||||
|
|
@ -883,8 +892,6 @@ pub fn canonicalize_pattern<'a>(
|
|||
let problem = MalformedPatternProblem::QualifiedIdentifier;
|
||||
malformed_pattern(env, problem, region)
|
||||
}
|
||||
|
||||
Stmt(_) => internal_error!("should have been handled in the parser"),
|
||||
};
|
||||
|
||||
Loc {
|
||||
|
|
|
|||
|
|
@ -196,10 +196,11 @@ impl<'a> Formattable for ValueDef<'a> {
|
|||
Expect { condition, .. } => condition.is_multiline(),
|
||||
ExpectFx { 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::*;
|
||||
match self {
|
||||
Annotation(loc_pattern, loc_annotation) => {
|
||||
|
|
@ -238,6 +239,7 @@ impl<'a> Formattable for ValueDef<'a> {
|
|||
buf.newline();
|
||||
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) {
|
||||
// Check if this is an assignment into the unit/empty record, format as a Statement
|
||||
let is_statement = if let Pattern::RecordDestructure(collection) = pattern {
|
||||
// Check if this is an assignment into the unit value
|
||||
let is_unit_assignment = if let Pattern::RecordDestructure(collection) = pattern {
|
||||
collection.is_empty()
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
// 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);
|
||||
buf.indent(indent);
|
||||
buf.push_str(" =");
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ impl<'a> Formattable for Expr<'a> {
|
|||
Tuple(fields) => is_collection_multiline(fields),
|
||||
RecordUpdate { 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) => {
|
||||
fmt_str_literal(buf, *literal, indent);
|
||||
}
|
||||
Var { module_name, ident } => {
|
||||
Var {
|
||||
module_name,
|
||||
ident,
|
||||
suffixed,
|
||||
} => {
|
||||
buf.indent(indent);
|
||||
if !module_name.is_empty() {
|
||||
buf.push_str(module_name);
|
||||
|
|
@ -176,6 +179,11 @@ impl<'a> Formattable for Expr<'a> {
|
|||
}
|
||||
|
||||
buf.push_str(ident);
|
||||
|
||||
let count: u8 = *suffixed;
|
||||
for _ in 0..count {
|
||||
buf.push('!');
|
||||
}
|
||||
}
|
||||
Underscore(name) => {
|
||||
buf.indent(indent);
|
||||
|
|
@ -513,10 +521,6 @@ impl<'a> Formattable for Expr<'a> {
|
|||
MultipleRecordBuilders { .. } => {}
|
||||
UnappliedRecordBuilder { .. } => {}
|
||||
IngestedFile(_, _) => {}
|
||||
Suffixed(sub_expr) => {
|
||||
sub_expr.format_with_options(buf, parens, newlines, indent);
|
||||
buf.push('!');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ use crate::annotation::{Formattable, Newlines, Parens};
|
|||
use crate::expr::{fmt_str_literal, format_sq_literal};
|
||||
use crate::spaces::{fmt_comments_only, fmt_spaces, NewlineAt, INDENT};
|
||||
use crate::Buf;
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_parse::ast::{Base, CommentOrNewline, Pattern, PatternAs};
|
||||
|
||||
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::OpaqueRef(_)
|
||||
| Pattern::Apply(_, _)
|
||||
|
|
@ -82,7 +81,6 @@ impl<'a> Formattable for Pattern<'a> {
|
|||
Pattern::Tuple(patterns) | Pattern::List(patterns) => {
|
||||
patterns.iter().any(|p| p.is_multiline())
|
||||
}
|
||||
Pattern::Stmt(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,9 +88,16 @@ impl<'a> Formattable for Pattern<'a> {
|
|||
use self::Pattern::*;
|
||||
|
||||
match self {
|
||||
Identifier(string) => {
|
||||
Identifier {
|
||||
ident: string,
|
||||
suffixed,
|
||||
} => {
|
||||
buf.indent(indent);
|
||||
buf.push_str(string)
|
||||
buf.push_str(string);
|
||||
|
||||
for _ in 0..*suffixed {
|
||||
buf.push('!');
|
||||
}
|
||||
}
|
||||
Tag(name) | OpaqueRef(name) => {
|
||||
buf.indent(indent);
|
||||
|
|
@ -272,19 +277,23 @@ impl<'a> Formattable for Pattern<'a> {
|
|||
buf.indent(indent);
|
||||
buf.push_str(string);
|
||||
}
|
||||
QualifiedIdentifier { module_name, ident } => {
|
||||
QualifiedIdentifier {
|
||||
module_name,
|
||||
ident,
|
||||
suffixed,
|
||||
} => {
|
||||
buf.indent(indent);
|
||||
if !module_name.is_empty() {
|
||||
buf.push_str(module_name);
|
||||
buf.push('.');
|
||||
}
|
||||
|
||||
for _ in 0..*suffixed {
|
||||
buf.push('!');
|
||||
}
|
||||
|
||||
buf.push_str(ident);
|
||||
}
|
||||
|
||||
// Statement e.g. Suffixed with optional `{}=`
|
||||
// e.g. `Stdout.line! "Hello World"`
|
||||
Stmt(_) => internal_error!("should be desugared in parser into alternate pattern"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -567,6 +567,7 @@ impl<'a> RemoveSpaces<'a> for ValueDef<'a> {
|
|||
condition: arena.alloc(condition.remove_spaces(arena)),
|
||||
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::RecordBuilder(a) => Expr::RecordBuilder(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::Tag(a) => Expr::Tag(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::SpaceAfter(a, _) => a.remove_spaces(arena),
|
||||
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> {
|
||||
fn remove_spaces(&self, arena: &'a Bump) -> Self {
|
||||
match *self {
|
||||
Pattern::Identifier(a) => Pattern::Identifier(a),
|
||||
Pattern::Identifier { ident, suffixed } => Pattern::Identifier { ident, suffixed },
|
||||
Pattern::Tag(a) => Pattern::Tag(a),
|
||||
Pattern::OpaqueRef(a) => Pattern::OpaqueRef(a),
|
||||
Pattern::Apply(a, b) => Pattern::Apply(
|
||||
|
|
@ -825,9 +833,15 @@ impl<'a> RemoveSpaces<'a> for Pattern<'a> {
|
|||
Pattern::Underscore(a) => Pattern::Underscore(a),
|
||||
Pattern::Malformed(a) => Pattern::Malformed(a),
|
||||
Pattern::MalformedIdent(a, b) => Pattern::MalformedIdent(a, remove_spaces_bad_ident(b)),
|
||||
Pattern::QualifiedIdentifier { module_name, ident } => {
|
||||
Pattern::QualifiedIdentifier { module_name, ident }
|
||||
}
|
||||
Pattern::QualifiedIdentifier {
|
||||
module_name,
|
||||
ident,
|
||||
suffixed,
|
||||
} => Pattern::QualifiedIdentifier {
|
||||
module_name,
|
||||
ident,
|
||||
suffixed,
|
||||
},
|
||||
Pattern::SpaceBefore(a, _) => a.remove_spaces(arena),
|
||||
Pattern::SpaceAfter(a, _) => a.remove_spaces(arena),
|
||||
Pattern::SingleQuote(a) => Pattern::SingleQuote(a),
|
||||
|
|
@ -837,7 +851,6 @@ impl<'a> RemoveSpaces<'a> for Pattern<'a> {
|
|||
opt_pattern_as
|
||||
.map(|(_, pattern_as)| ([].as_ref(), pattern_as.remove_spaces(arena))),
|
||||
),
|
||||
Pattern::Stmt(a) => Pattern::Stmt(a),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,7 +212,12 @@ fn generate_entry_docs(
|
|||
match either_index.split() {
|
||||
Err(value_index) => match &defs.value_defs[value_index.index()] {
|
||||
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
|
||||
if let Some(ident_id) = ident_ids.get_id(identifier) {
|
||||
let name = identifier.to_string();
|
||||
|
|
@ -233,7 +238,12 @@ fn generate_entry_docs(
|
|||
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
|
||||
if let Some(ident_id) = ident_ids.get_id(identifier) {
|
||||
let doc_def = DocDef {
|
||||
|
|
@ -249,7 +259,12 @@ fn generate_entry_docs(
|
|||
}
|
||||
|
||||
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
|
||||
if let Some(ident_id) = ident_ids.get_id(identifier) {
|
||||
let doc_def = DocDef {
|
||||
|
|
@ -275,6 +290,8 @@ fn generate_entry_docs(
|
|||
ValueDef::ExpectFx { .. } => {
|
||||
// Don't generate docs for `expect-fx`s
|
||||
}
|
||||
|
||||
ValueDef::Stmt(_) => todo!(),
|
||||
},
|
||||
|
||||
Ok(type_index) => match &defs.type_defs[type_index.index()] {
|
||||
|
|
@ -285,7 +302,12 @@ fn generate_entry_docs(
|
|||
let mut type_vars = Vec::new();
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
@ -319,7 +341,12 @@ fn generate_entry_docs(
|
|||
let mut type_vars = Vec::new();
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
@ -343,7 +370,12 @@ fn generate_entry_docs(
|
|||
let mut type_vars = Vec::new();
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
@ -605,7 +637,8 @@ fn type_to_docs(in_func_type_ann: bool, type_annotation: ast::TypeAnnotation) ->
|
|||
.vars
|
||||
.iter()
|
||||
.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,
|
||||
})
|
||||
.collect(),
|
||||
|
|
|
|||
|
|
@ -5647,7 +5647,15 @@ fn value_def_from_imports<'a>(
|
|||
);
|
||||
};
|
||||
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);
|
||||
Some(ValueDef::AnnotatedBody {
|
||||
ann_pattern: ident,
|
||||
|
|
|
|||
|
|
@ -267,9 +267,6 @@ pub enum Expr<'a> {
|
|||
// Collection Literals
|
||||
List(Collection<'a, &'a Loc<Expr<'a>>>),
|
||||
|
||||
/// An expression followed by `!``
|
||||
Suffixed(&'a Expr<'a>),
|
||||
|
||||
RecordUpdate {
|
||||
update: &'a Loc<Expr<'a>>,
|
||||
fields: Collection<'a, Loc<AssignedField<'a, Expr<'a>>>>,
|
||||
|
|
@ -349,6 +346,25 @@ pub enum 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)]
|
||||
pub struct PrecedenceConflict<'a> {
|
||||
pub whole_region: Region,
|
||||
|
|
@ -459,6 +475,8 @@ pub enum ValueDef<'a> {
|
|||
condition: &'a Loc<Expr<'a>>,
|
||||
preceding_comment: Region,
|
||||
},
|
||||
|
||||
Stmt(&'a Loc<Expr<'a>>),
|
||||
}
|
||||
|
||||
#[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) {
|
||||
match self
|
||||
.tags
|
||||
|
|
@ -601,16 +660,8 @@ impl<'a> Defs<'a> {
|
|||
if let Err(value_index) = tag.split() {
|
||||
let index = value_index.index();
|
||||
|
||||
if let ValueDef::Body(_, expr) = &self.value_defs[index] {
|
||||
// The Suffixed has arguments applied e.g. `Stdout.line! "Hello World"`
|
||||
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 {
|
||||
if let ValueDef::Body(_, loc_expr) = &self.value_defs[index] {
|
||||
if is_loc_expr_suffixed(**loc_expr) {
|
||||
return Some((tag_index, index));
|
||||
}
|
||||
}
|
||||
|
|
@ -872,10 +923,14 @@ impl<'a> PatternAs<'a> {
|
|||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum Pattern<'a> {
|
||||
// Identifier
|
||||
Identifier(&'a str),
|
||||
Identifier {
|
||||
ident: &'a str,
|
||||
suffixed: u8,
|
||||
},
|
||||
QualifiedIdentifier {
|
||||
module_name: &'a str,
|
||||
ident: &'a str,
|
||||
suffixed: u8,
|
||||
},
|
||||
|
||||
Tag(&'a str),
|
||||
|
|
@ -928,11 +983,10 @@ pub enum Pattern<'a> {
|
|||
// Malformed
|
||||
Malformed(&'a str),
|
||||
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)]
|
||||
pub enum Base {
|
||||
Octal,
|
||||
|
|
@ -996,11 +1050,22 @@ impl<'a> Pattern<'a> {
|
|||
// { x, y } : { x : Int, y ? Bool }
|
||||
// { x, y ? False } = rec
|
||||
OptionalField(x, _) => match other {
|
||||
Identifier(y) | OptionalField(y, _) => x == y,
|
||||
Identifier {
|
||||
ident: y,
|
||||
suffixed: 0,
|
||||
}
|
||||
| OptionalField(y, _) => x == y,
|
||||
_ => false,
|
||||
},
|
||||
Identifier(x) => match other {
|
||||
Identifier(y) | OptionalField(y, _) => x == y,
|
||||
Identifier {
|
||||
ident: x,
|
||||
suffixed: a,
|
||||
} => match other {
|
||||
Identifier {
|
||||
ident: y,
|
||||
suffixed: b,
|
||||
} => x == y && a == b,
|
||||
OptionalField(y, _) => x == y,
|
||||
_ => false,
|
||||
},
|
||||
NumLiteral(x) => {
|
||||
|
|
@ -1061,13 +1126,15 @@ impl<'a> Pattern<'a> {
|
|||
QualifiedIdentifier {
|
||||
module_name: a,
|
||||
ident: x,
|
||||
suffixed: i,
|
||||
} => {
|
||||
if let QualifiedIdentifier {
|
||||
module_name: b,
|
||||
ident: y,
|
||||
suffixed: j,
|
||||
} = other
|
||||
{
|
||||
a == b && x == y
|
||||
a == b && x == y && i == j
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
@ -1130,14 +1197,6 @@ impl<'a> Pattern<'a> {
|
|||
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 {
|
||||
$t::SpaceBefore(item, before) => {
|
||||
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) => {
|
||||
Spaces {
|
||||
before,
|
||||
|
|
@ -1667,7 +1733,6 @@ impl<'a> Malformed for Expr<'a> {
|
|||
PrecedenceConflict(_) |
|
||||
MultipleRecordBuilders(_) |
|
||||
UnappliedRecordBuilder(_) => true,
|
||||
Suffixed(expr) => expr.is_malformed(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1762,10 +1827,9 @@ impl<'a> Malformed for Pattern<'a> {
|
|||
use Pattern::*;
|
||||
|
||||
match self {
|
||||
Identifier(_) |
|
||||
Identifier{ .. } |
|
||||
Tag(_) |
|
||||
OpaqueRef(_) |
|
||||
Stmt(_) => false,
|
||||
OpaqueRef(_) => false,
|
||||
Apply(func, args) => func.is_malformed() || args.iter().any(|arg| arg.is_malformed()),
|
||||
RecordDestructure(items) => items.iter().any(|item| item.is_malformed()),
|
||||
RequiredField(_, pat) => pat.is_malformed(),
|
||||
|
|
@ -1903,6 +1967,7 @@ impl<'a> Malformed for ValueDef<'a> {
|
|||
condition,
|
||||
preceding_comment: _,
|
||||
} => condition.is_malformed(),
|
||||
ValueDef::Stmt(loc_expr) => loc_expr.is_malformed(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::ast::{
|
||||
AssignedField, Collection, CommentOrNewline, Defs, Expr, ExtractSpaces, Implements,
|
||||
ImplementsAbilities, Pattern, RecordBuilderField, Spaceable, Spaces, TypeAnnotation, TypeDef,
|
||||
TypeHeader, ValueDef,
|
||||
is_valid_suffixed_statement, AssignedField, Collection, CommentOrNewline, Defs, Expr,
|
||||
ExtractSpaces, Implements, ImplementsAbilities, Pattern, RecordBuilderField, Spaceable, Spaces,
|
||||
TypeAnnotation, TypeDef, TypeHeader, ValueDef,
|
||||
};
|
||||
use crate::blankspace::{
|
||||
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>> {
|
||||
line_min_indent(move |arena, state: State<'a>, min_indent: u32| {
|
||||
let (_, expr, state, new_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 (_, expr, state) =
|
||||
loc_possibly_negative_or_negated_term(options).parse(arena, state, min_indent)?;
|
||||
|
||||
let initial_state = state.clone();
|
||||
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)),
|
||||
Ok((_, spaces_before_op, state)) => {
|
||||
let expr_state = ExprState {
|
||||
|
|
@ -350,14 +338,7 @@ fn expr_operator_chain<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a
|
|||
end,
|
||||
};
|
||||
|
||||
parse_expr_end(
|
||||
new_min_indent,
|
||||
options,
|
||||
expr_state,
|
||||
arena,
|
||||
state,
|
||||
initial_state,
|
||||
)
|
||||
parse_expr_end(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
|
||||
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)) => {
|
||||
// // 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.
|
||||
let opt_tag_and_args: Option<(&str, Region, &[Loc<Pattern>])> = match loc_pattern.value
|
||||
{
|
||||
|
|
@ -725,60 +681,197 @@ pub fn parse_single_def<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
// Otherwise, this is a def or alias.
|
||||
match operator().parse(arena, state, min_indent) {
|
||||
Ok((_, BinOp::Assignment, state)) => {
|
||||
let parse_def_expr = space0_before_e(
|
||||
increment_min_indent(expr_start(options)),
|
||||
EExpr::IndentEnd,
|
||||
// This may be a def or alias.
|
||||
let operator_result = operator().parse(arena, state.clone(), min_indent);
|
||||
|
||||
if let Ok((_, BinOp::Assignment, state)) = operator_result {
|
||||
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 =
|
||||
ValueDef::Body(arena.alloc(loc_pattern), &*arena.alloc(loc_def_expr));
|
||||
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
|
||||
if crate::ast::is_loc_expr_suffixed(loc_def_expr) {
|
||||
// Take the suffixed value and make it a e.g. Body(`{}=`, Apply(Var(...)))
|
||||
// we will keep the pattern `loc_pattern` for the new Defs
|
||||
let mut defs = Defs::default();
|
||||
defs.push_value_def(
|
||||
ValueDef::Body(
|
||||
arena.alloc(Loc::at(
|
||||
region,
|
||||
Pattern::RecordDestructure(Collection::empty()),
|
||||
)),
|
||||
arena.alloc(Loc::at(region, loc_def_expr.value.extract_spaces().item)),
|
||||
),
|
||||
region,
|
||||
&[],
|
||||
&[],
|
||||
);
|
||||
|
||||
let (_, loc_def_expr, state) =
|
||||
parse_def_expr.parse(arena, state, min_indent)?;
|
||||
let (progress, expr, state_post_defs) =
|
||||
parse_defs_expr(options, min_indent, defs, arena, state.clone())?;
|
||||
|
||||
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);
|
||||
// let parse_defs_expr_result = dbg!(parse_defs_expr(
|
||||
// options,
|
||||
// min_indent + 1,
|
||||
// defs.clone(),
|
||||
// arena,
|
||||
// state_after_def_expr.clone(),
|
||||
// ));
|
||||
|
||||
// Handle the specific case when the first line of an assignment is actually a suffixed statement
|
||||
if is_loc_expr_suffixed(loc_def_expr) {
|
||||
// Take the suffixed value and make it a e.g. Body(`{}=`, Apply(Suffixed(...)))
|
||||
// we will keep the pattern `loc_pattern` for the new Defs
|
||||
let mut defs = Defs::default();
|
||||
defs.push_value_def(
|
||||
ValueDef::Body(
|
||||
arena.alloc(Loc::at(
|
||||
region,
|
||||
Pattern::RecordDestructure(Collection::empty()),
|
||||
)),
|
||||
arena.alloc(Loc::at(
|
||||
region,
|
||||
loc_def_expr.value.extract_spaces().item,
|
||||
)),
|
||||
),
|
||||
// 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((
|
||||
progress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::Second(ValueDef::Body(
|
||||
arena.alloc(loc_pattern),
|
||||
arena.alloc(Loc::at(region, expr)),
|
||||
)),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state_post_defs,
|
||||
));
|
||||
|
||||
// } else {
|
||||
// parse_defs_expr_result?;
|
||||
// };
|
||||
}
|
||||
|
||||
return Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::Second(value_def),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
));
|
||||
}
|
||||
|
||||
if let Ok((_, BinOp::IsAliasType, state)) = operator_result {
|
||||
// the increment_min_indent here is probably _wrong_, since alias_signature_with_space_before does
|
||||
// that internally.
|
||||
// TODO: re-evaluate this
|
||||
let parser = increment_min_indent(alias_signature_with_space_before());
|
||||
let (_, ann_type, state) = parser.parse(arena, state, min_indent)?;
|
||||
let region = Region::span_across(&loc_pattern.region, &ann_type.region);
|
||||
|
||||
match &loc_pattern.value.extract_spaces().item {
|
||||
Pattern::Apply(
|
||||
Loc {
|
||||
value: Pattern::Tag(name),
|
||||
..
|
||||
},
|
||||
alias_arguments,
|
||||
) => {
|
||||
let name = Loc::at(loc_pattern.region, *name);
|
||||
let header = TypeHeader {
|
||||
name,
|
||||
vars: alias_arguments,
|
||||
};
|
||||
|
||||
let type_def = TypeDef::Alias {
|
||||
header,
|
||||
ann: ann_type,
|
||||
};
|
||||
|
||||
return Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::First(type_def),
|
||||
region,
|
||||
&[],
|
||||
&[],
|
||||
);
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
));
|
||||
}
|
||||
Pattern::Tag(name) => {
|
||||
let name = Loc::at(loc_pattern.region, *name);
|
||||
let pattern_arguments: &'a [Loc<Pattern<'a>>] = &[];
|
||||
let header = TypeHeader {
|
||||
name,
|
||||
vars: pattern_arguments,
|
||||
};
|
||||
|
||||
let (progress, expr, state_post_defs) =
|
||||
parse_defs_expr(options, min_indent, defs, arena, state.clone())?;
|
||||
let type_def = TypeDef::Alias {
|
||||
header,
|
||||
ann: ann_type,
|
||||
};
|
||||
|
||||
return Ok((
|
||||
progress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::Second(ValueDef::Body(
|
||||
arena.alloc(loc_pattern),
|
||||
arena.alloc(Loc::at(region, expr)),
|
||||
)),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state_post_defs,
|
||||
));
|
||||
}
|
||||
return Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::First(type_def),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
let value_def = ValueDef::Annotation(loc_pattern, ann_type);
|
||||
|
||||
Ok((
|
||||
return Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::Second(value_def),
|
||||
|
|
@ -786,158 +879,107 @@ pub fn parse_single_def<'a>(
|
|||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
))
|
||||
}
|
||||
Ok((_, BinOp::IsAliasType, state)) => {
|
||||
// the increment_min_indent here is probably _wrong_, since alias_signature_with_space_before does
|
||||
// that internally.
|
||||
// TODO: re-evaluate this
|
||||
let parser = increment_min_indent(alias_signature_with_space_before());
|
||||
let (_, ann_type, state) = parser.parse(arena, state, min_indent)?;
|
||||
let region = Region::span_across(&loc_pattern.region, &ann_type.region);
|
||||
|
||||
match &loc_pattern.value.extract_spaces().item {
|
||||
Pattern::Apply(
|
||||
Loc {
|
||||
value: Pattern::Tag(name),
|
||||
..
|
||||
},
|
||||
alias_arguments,
|
||||
) => {
|
||||
let name = Loc::at(loc_pattern.region, *name);
|
||||
let header = TypeHeader {
|
||||
name,
|
||||
vars: alias_arguments,
|
||||
};
|
||||
|
||||
let type_def = TypeDef::Alias {
|
||||
header,
|
||||
ann: ann_type,
|
||||
};
|
||||
|
||||
Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::First(type_def),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
))
|
||||
}
|
||||
Pattern::Tag(name) => {
|
||||
let name = Loc::at(loc_pattern.region, *name);
|
||||
let pattern_arguments: &'a [Loc<Pattern<'a>>] = &[];
|
||||
let header = TypeHeader {
|
||||
name,
|
||||
vars: pattern_arguments,
|
||||
};
|
||||
|
||||
let type_def = TypeDef::Alias {
|
||||
header,
|
||||
ann: ann_type,
|
||||
};
|
||||
|
||||
Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::First(type_def),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
))
|
||||
}
|
||||
_ => {
|
||||
let value_def = ValueDef::Annotation(loc_pattern, ann_type);
|
||||
|
||||
Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::Second(value_def),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
))
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok((_, BinOp::IsOpaqueType, state)) => {
|
||||
let (_, (signature, derived), state) =
|
||||
opaque_signature_with_space_before().parse(arena, state, min_indent + 1)?;
|
||||
let region = Region::span_across(&loc_pattern.region, &signature.region);
|
||||
};
|
||||
|
||||
match &loc_pattern.value.extract_spaces().item {
|
||||
Pattern::Apply(
|
||||
Loc {
|
||||
value: Pattern::Tag(name),
|
||||
..
|
||||
},
|
||||
alias_arguments,
|
||||
) => {
|
||||
let name = Loc::at(loc_pattern.region, *name);
|
||||
let header = TypeHeader {
|
||||
name,
|
||||
vars: alias_arguments,
|
||||
};
|
||||
if let Ok((_, BinOp::IsOpaqueType, state)) = operator_result {
|
||||
let (_, (signature, derived), state) =
|
||||
opaque_signature_with_space_before().parse(arena, state, min_indent + 1)?;
|
||||
let region = Region::span_across(&loc_pattern.region, &signature.region);
|
||||
|
||||
let type_def = TypeDef::Opaque {
|
||||
header,
|
||||
typ: signature,
|
||||
derived,
|
||||
};
|
||||
match &loc_pattern.value.extract_spaces().item {
|
||||
Pattern::Apply(
|
||||
Loc {
|
||||
value: Pattern::Tag(name),
|
||||
..
|
||||
},
|
||||
alias_arguments,
|
||||
) => {
|
||||
let name = Loc::at(loc_pattern.region, *name);
|
||||
let header = TypeHeader {
|
||||
name,
|
||||
vars: alias_arguments,
|
||||
};
|
||||
|
||||
Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::First(type_def),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
))
|
||||
}
|
||||
Pattern::Tag(name) => {
|
||||
let name = Loc::at(loc_pattern.region, *name);
|
||||
let pattern_arguments: &'a [Loc<Pattern<'a>>] = &[];
|
||||
let header = TypeHeader {
|
||||
name,
|
||||
vars: pattern_arguments,
|
||||
};
|
||||
let type_def = TypeDef::Opaque {
|
||||
header,
|
||||
typ: signature,
|
||||
derived,
|
||||
};
|
||||
|
||||
let type_def = TypeDef::Opaque {
|
||||
header,
|
||||
typ: signature,
|
||||
derived,
|
||||
};
|
||||
return Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::First(type_def),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
));
|
||||
}
|
||||
Pattern::Tag(name) => {
|
||||
let name = Loc::at(loc_pattern.region, *name);
|
||||
let pattern_arguments: &'a [Loc<Pattern<'a>>] = &[];
|
||||
let header = TypeHeader {
|
||||
name,
|
||||
vars: pattern_arguments,
|
||||
};
|
||||
|
||||
Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::First(type_def),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
))
|
||||
}
|
||||
_ => {
|
||||
let value_def = ValueDef::Annotation(loc_pattern, signature);
|
||||
let type_def = TypeDef::Opaque {
|
||||
header,
|
||||
typ: signature,
|
||||
derived,
|
||||
};
|
||||
|
||||
Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::Second(value_def),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
))
|
||||
}
|
||||
return Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::First(type_def),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
let value_def = ValueDef::Annotation(loc_pattern, signature);
|
||||
|
||||
return Ok((
|
||||
MadeProgress,
|
||||
Some(SingleDef {
|
||||
type_or_value: Either::Second(value_def),
|
||||
region,
|
||||
spaces_before: spaces_before_current,
|
||||
}),
|
||||
state,
|
||||
));
|
||||
}
|
||||
}
|
||||
_ => Ok((MadeProgress, None, initial)),
|
||||
};
|
||||
|
||||
// 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((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 value_def = get_value_def(preceding_comment, loc_def_expr);
|
||||
|
||||
Ok((
|
||||
|
|
@ -1142,6 +1185,7 @@ fn parse_defs_end<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SingleDef<'a> {
|
||||
pub type_or_value: Either<TypeDef<'a>, ValueDef<'a>>,
|
||||
pub region: Region,
|
||||
|
|
@ -1163,31 +1207,34 @@ fn parse_defs_expr<'a>(
|
|||
|
||||
match parse_final_expr.parse(arena, state.clone(), min_indent) {
|
||||
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,
|
||||
EExpr::DefMissingFinalExpr2(arena.alloc(fail), state.pos()),
|
||||
));
|
||||
}
|
||||
Ok((_, loc_ret, state)) => {
|
||||
return Ok((
|
||||
MadeProgress,
|
||||
Expr::Defs(arena.alloc(def_state), arena.alloc(loc_ret)),
|
||||
state,
|
||||
));
|
||||
))
|
||||
}
|
||||
Ok((_, loc_ret, state)) => Ok((
|
||||
MadeProgress,
|
||||
Expr::Defs(arena.alloc(def_state), arena.alloc(loc_ret)),
|
||||
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>> {
|
||||
increment_min_indent(specialize_err(
|
||||
EExpr::Type,
|
||||
|
|
@ -1773,6 +1820,7 @@ fn parse_expr_end<'a>(
|
|||
Expr::Var {
|
||||
module_name: "",
|
||||
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 {
|
||||
Expr::Var { module_name, ident } => {
|
||||
Expr::Var {
|
||||
module_name,
|
||||
ident,
|
||||
suffixed,
|
||||
} => {
|
||||
if module_name.is_empty() {
|
||||
Pattern::Identifier(ident)
|
||||
Pattern::Identifier { ident, suffixed }
|
||||
} else {
|
||||
Pattern::QualifiedIdentifier { module_name, ident }
|
||||
Pattern::QualifiedIdentifier {
|
||||
module_name,
|
||||
ident,
|
||||
suffixed,
|
||||
}
|
||||
}
|
||||
}
|
||||
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::SingleQuote(string) => Pattern::SingleQuote(string),
|
||||
Expr::MalformedIdent(string, problem) => Pattern::MalformedIdent(string, problem),
|
||||
Expr::Suffixed(_) => todo!(),
|
||||
};
|
||||
|
||||
// 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(
|
||||
arena.alloc(assigned_expr_field_to_pattern_help(arena, nested)?),
|
||||
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,
|
||||
// e.g. `foo` in `foo.bar.baz`
|
||||
let mut answer = match iter.next() {
|
||||
Some(Accessor::RecordField(ident)) if suffixed => {
|
||||
Expr::Suffixed(arena.alloc(Expr::Var { module_name, ident }))
|
||||
}
|
||||
Some(Accessor::RecordField(ident)) => Expr::Var { module_name, ident },
|
||||
Some(Accessor::RecordField(ident)) => Expr::Var {
|
||||
module_name,
|
||||
ident,
|
||||
suffixed,
|
||||
},
|
||||
Some(Accessor::TupleIndex(_)) => {
|
||||
// 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`,
|
||||
|
|
|
|||
|
|
@ -51,8 +51,11 @@ pub fn loc_pattern_help<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, EPattern<'a>>
|
|||
let pattern_state = state.clone();
|
||||
|
||||
// Return early with the suffixed statement
|
||||
if let Pattern::BangSuffixed(_,_) = pattern.value {
|
||||
return Ok((MadeProgress, pattern, pattern_state));
|
||||
match pattern.value {
|
||||
Pattern::Identifier { suffixed, .. } if suffixed > 0 => {
|
||||
return Ok((MadeProgress, pattern, pattern_state))
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let (pattern_spaces, state) =
|
||||
|
|
@ -144,7 +147,15 @@ fn loc_tag_pattern_arg<'a>(
|
|||
|
||||
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())))
|
||||
} else {
|
||||
Ok((
|
||||
|
|
@ -166,7 +177,10 @@ pub fn loc_implements_parser<'a>() -> impl Parser<'a, Loc<Implements<'a>>, EPatt
|
|||
|_arena, state, progress, pattern| {
|
||||
if matches!(
|
||||
pattern.value,
|
||||
Pattern::Identifier(crate::keyword::IMPLEMENTS)
|
||||
Pattern::Identifier {
|
||||
ident: crate::keyword::IMPLEMENTS,
|
||||
..
|
||||
}
|
||||
) {
|
||||
Ok((
|
||||
progress,
|
||||
|
|
@ -400,14 +414,17 @@ fn loc_ident_pattern_help<'a>(
|
|||
} if suffixed > 0 => {
|
||||
if module_name.is_empty() && parts.len() == 1 {
|
||||
if let Accessor::RecordField(var) = &parts[0] {
|
||||
return Ok((
|
||||
Ok((
|
||||
MadeProgress,
|
||||
Loc {
|
||||
region: loc_ident.region,
|
||||
value: Pattern::BangSuffixed(var, suffixed),
|
||||
value: Pattern::Identifier {
|
||||
ident: var,
|
||||
suffixed,
|
||||
},
|
||||
},
|
||||
state,
|
||||
));
|
||||
))
|
||||
} else {
|
||||
internal_error!("unexpected suffixed TupleIndex");
|
||||
}
|
||||
|
|
@ -416,7 +433,11 @@ fn loc_ident_pattern_help<'a>(
|
|||
MadeProgress,
|
||||
Loc {
|
||||
region: loc_ident.region,
|
||||
value: Pattern::BangSuffixed(arena.alloc(format!("{}.{}", module_name, var)), suffixed),
|
||||
value: Pattern::QualifiedIdentifier {
|
||||
module_name,
|
||||
ident: var,
|
||||
suffixed,
|
||||
},
|
||||
},
|
||||
state,
|
||||
));
|
||||
|
|
@ -442,7 +463,10 @@ fn loc_ident_pattern_help<'a>(
|
|||
MadeProgress,
|
||||
Loc {
|
||||
region: loc_ident.region,
|
||||
value: Pattern::Identifier(var),
|
||||
value: Pattern::Identifier {
|
||||
ident: var,
|
||||
suffixed: 0,
|
||||
},
|
||||
},
|
||||
state,
|
||||
));
|
||||
|
|
@ -603,9 +627,18 @@ fn record_pattern_field<'a>() -> impl Parser<'a, Loc<Pattern<'a>>, PRecord<'a>>
|
|||
None => {
|
||||
let Loc { value, region } = loc_label;
|
||||
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 {
|
||||
Pattern::Identifier(value)
|
||||
Pattern::Identifier {
|
||||
ident: value,
|
||||
suffixed: 0,
|
||||
}
|
||||
};
|
||||
|
||||
Ok((MadeProgress, Loc::at(region, value), state))
|
||||
|
|
|
|||
|
|
@ -70,7 +70,13 @@ fn check_type_alias<'a>(
|
|||
var_names.reserve(vars.len());
|
||||
for var in vars {
|
||||
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 {
|
||||
return Err(ETypeInlineAlias::ArgumentNotLowercase(var.region.start()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ mod test_parse {
|
|||
let expr = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "name",
|
||||
suffixed: false,
|
||||
suffixed: 0,
|
||||
});
|
||||
|
||||
bumpalo::vec![in arena;
|
||||
|
|
@ -192,7 +192,7 @@ mod test_parse {
|
|||
let expr = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "name",
|
||||
suffixed: false,
|
||||
suffixed: 0,
|
||||
});
|
||||
|
||||
bumpalo::vec![in arena;
|
||||
|
|
@ -238,7 +238,7 @@ mod test_parse {
|
|||
let expr = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "name",
|
||||
suffixed: false,
|
||||
suffixed: 0,
|
||||
});
|
||||
|
||||
bumpalo::vec![in arena;
|
||||
|
|
@ -254,13 +254,13 @@ mod test_parse {
|
|||
let expr1 = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "name",
|
||||
suffixed: false,
|
||||
suffixed: 0,
|
||||
});
|
||||
|
||||
let expr2 = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "project",
|
||||
suffixed: false,
|
||||
suffixed: 0,
|
||||
});
|
||||
|
||||
bumpalo::vec![in arena;
|
||||
|
|
@ -281,13 +281,13 @@ mod test_parse {
|
|||
let expr1 = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "name",
|
||||
suffixed: false,
|
||||
suffixed: 0,
|
||||
});
|
||||
|
||||
let expr2 = arena.alloc(Var {
|
||||
module_name: "",
|
||||
ident: "project",
|
||||
suffixed: false,
|
||||
suffixed: 0,
|
||||
});
|
||||
|
||||
bumpalo::vec![in arena;
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-3 Identifier(
|
||||
"foo",
|
||||
),
|
||||
@0-3 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
@6-27 TagUnion {
|
||||
ext: None,
|
||||
tags: [
|
||||
|
|
@ -40,9 +41,10 @@ Defs(
|
|||
},
|
||||
),
|
||||
AnnotatedBody {
|
||||
ann_pattern: @0-3 Identifier(
|
||||
"foo",
|
||||
),
|
||||
ann_pattern: @0-3 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
ann_type: @6-27 TagUnion {
|
||||
ext: None,
|
||||
tags: [
|
||||
|
|
@ -63,9 +65,10 @@ Defs(
|
|||
],
|
||||
},
|
||||
comment: None,
|
||||
body_pattern: @28-31 Identifier(
|
||||
"foo",
|
||||
),
|
||||
body_pattern: @28-31 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
body_expr: @34-38 Tag(
|
||||
"True",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-3 Identifier(
|
||||
"foo",
|
||||
),
|
||||
@0-3 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
@6-28 TagUnion {
|
||||
ext: Some(
|
||||
@27-28 Wildcard,
|
||||
|
|
@ -42,9 +43,10 @@ Defs(
|
|||
},
|
||||
),
|
||||
AnnotatedBody {
|
||||
ann_pattern: @0-3 Identifier(
|
||||
"foo",
|
||||
),
|
||||
ann_pattern: @0-3 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
ann_type: @6-28 TagUnion {
|
||||
ext: Some(
|
||||
@27-28 Wildcard,
|
||||
|
|
@ -67,9 +69,10 @@ Defs(
|
|||
],
|
||||
},
|
||||
comment: None,
|
||||
body_pattern: @29-32 Identifier(
|
||||
"foo",
|
||||
),
|
||||
body_pattern: @29-32 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
body_expr: @35-39 Tag(
|
||||
"True",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -18,12 +18,14 @@ Defs(
|
|||
Annotation(
|
||||
@0-8 RecordDestructure(
|
||||
[
|
||||
@2-3 Identifier(
|
||||
"x",
|
||||
),
|
||||
@5-7 Identifier(
|
||||
"y",
|
||||
),
|
||||
@2-3 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@5-7 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
@11-14 Apply(
|
||||
|
|
@ -35,12 +37,14 @@ Defs(
|
|||
AnnotatedBody {
|
||||
ann_pattern: @0-8 RecordDestructure(
|
||||
[
|
||||
@2-3 Identifier(
|
||||
"x",
|
||||
),
|
||||
@5-7 Identifier(
|
||||
"y",
|
||||
),
|
||||
@2-3 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@5-7 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
ann_type: @11-14 Apply(
|
||||
|
|
@ -51,12 +55,14 @@ Defs(
|
|||
comment: None,
|
||||
body_pattern: @15-23 RecordDestructure(
|
||||
[
|
||||
@17-18 Identifier(
|
||||
"x",
|
||||
),
|
||||
@20-21 Identifier(
|
||||
"y",
|
||||
),
|
||||
@17-18 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@20-21 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
body_expr: @26-49 Record(
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ Defs(
|
|||
header: TypeHeader {
|
||||
name: @0-6 "UserId",
|
||||
vars: [
|
||||
@7-8 Identifier(
|
||||
"x",
|
||||
),
|
||||
@7-8 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
ann: @11-25 TagUnion {
|
||||
|
|
@ -47,9 +48,10 @@ Defs(
|
|||
"UserId",
|
||||
),
|
||||
[
|
||||
@7-8 Identifier(
|
||||
"x",
|
||||
),
|
||||
@7-8 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
ann_type: @11-25 TagUnion {
|
||||
|
|
@ -73,9 +75,10 @@ Defs(
|
|||
"UserId",
|
||||
),
|
||||
[
|
||||
@33-34 Identifier(
|
||||
"x",
|
||||
),
|
||||
@33-34 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
body_expr: @37-46 Apply(
|
||||
|
|
|
|||
|
|
@ -18,12 +18,14 @@ Defs(
|
|||
Annotation(
|
||||
@0-8 Tuple(
|
||||
[
|
||||
@2-3 Identifier(
|
||||
"x",
|
||||
),
|
||||
@5-6 Identifier(
|
||||
"y",
|
||||
),
|
||||
@2-3 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@5-6 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
@11-14 Apply(
|
||||
|
|
@ -35,12 +37,14 @@ Defs(
|
|||
AnnotatedBody {
|
||||
ann_pattern: @0-8 Tuple(
|
||||
[
|
||||
@2-3 Identifier(
|
||||
"x",
|
||||
),
|
||||
@5-6 Identifier(
|
||||
"y",
|
||||
),
|
||||
@2-3 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@5-6 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
ann_type: @11-14 Apply(
|
||||
|
|
@ -51,12 +55,14 @@ Defs(
|
|||
comment: None,
|
||||
body_pattern: @15-23 Tuple(
|
||||
[
|
||||
@17-18 Identifier(
|
||||
"x",
|
||||
),
|
||||
@20-21 Identifier(
|
||||
"y",
|
||||
),
|
||||
@17-18 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@20-21 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
body_expr: @26-41 Tuple(
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ SpaceBefore(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@107-108 Identifier(
|
||||
"x",
|
||||
),
|
||||
@107-108 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@111-112 Num(
|
||||
"5",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"a",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@3-4 SpaceBefore(
|
||||
BoundVariable(
|
||||
"c",
|
||||
|
|
|
|||
|
|
@ -12,9 +12,10 @@ BinOps(
|
|||
@5-12 Apply(
|
||||
@5-10 Closure(
|
||||
[
|
||||
@6-7 Identifier(
|
||||
"x",
|
||||
),
|
||||
@6-7 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@9-10 Var {
|
||||
module_name: "",
|
||||
|
|
|
|||
|
|
@ -13,9 +13,10 @@ BinOps(
|
|||
@2-7 SpaceAfter(
|
||||
Closure(
|
||||
[
|
||||
@3-4 Identifier(
|
||||
"s",
|
||||
),
|
||||
@3-4 Identifier {
|
||||
ident: "s",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@6-7 Var {
|
||||
module_name: "",
|
||||
|
|
|
|||
|
|
@ -19,9 +19,10 @@ Defs {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-3 Identifier(
|
||||
"foo",
|
||||
),
|
||||
@0-3 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
@6-7 Num(
|
||||
"1",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ Defs(
|
|||
vars: [
|
||||
@3-4 SpaceAfter(
|
||||
SpaceBefore(
|
||||
Identifier(
|
||||
"h",
|
||||
),
|
||||
Identifier {
|
||||
ident: "h",
|
||||
suffixed: 0,
|
||||
},
|
||||
[
|
||||
LineComment(
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ Defs(
|
|||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 SpaceAfter(
|
||||
Identifier(
|
||||
"w",
|
||||
),
|
||||
Identifier {
|
||||
ident: "w",
|
||||
suffixed: 0,
|
||||
},
|
||||
[
|
||||
LineComment(
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ Defs(
|
|||
value_defs: [
|
||||
Body(
|
||||
@0-1 SpaceAfter(
|
||||
Identifier(
|
||||
"t",
|
||||
),
|
||||
Identifier {
|
||||
ident: "t",
|
||||
suffixed: 0,
|
||||
},
|
||||
[
|
||||
LineComment(
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"a",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@2-3 BoundVariable(
|
||||
"b",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@ Defs(
|
|||
"Email",
|
||||
),
|
||||
[
|
||||
@6-9 Identifier(
|
||||
"str",
|
||||
),
|
||||
@6-9 Identifier {
|
||||
ident: "str",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
@12-36 Apply(
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@ SpaceBefore(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@48-49 Identifier(
|
||||
"x",
|
||||
),
|
||||
@52-53 Num(
|
||||
@46-47 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@50-51 Num(
|
||||
"5",
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-5 Identifier(
|
||||
"table",
|
||||
),
|
||||
@0-5 Identifier {
|
||||
ident: "table",
|
||||
suffixed: 0,
|
||||
},
|
||||
@8-44 Function(
|
||||
[
|
||||
@8-35 Record {
|
||||
|
|
@ -54,9 +55,10 @@ Defs(
|
|||
),
|
||||
),
|
||||
AnnotatedBody {
|
||||
ann_pattern: @0-5 Identifier(
|
||||
"table",
|
||||
),
|
||||
ann_pattern: @0-5 Identifier {
|
||||
ident: "table",
|
||||
suffixed: 0,
|
||||
},
|
||||
ann_type: @8-44 Function(
|
||||
[
|
||||
@8-35 Record {
|
||||
|
|
@ -91,16 +93,18 @@ Defs(
|
|||
),
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @45-50 Identifier(
|
||||
"table",
|
||||
),
|
||||
body_pattern: @45-50 Identifier {
|
||||
ident: "table",
|
||||
suffixed: 0,
|
||||
},
|
||||
body_expr: @53-89 Closure(
|
||||
[
|
||||
@54-62 RecordDestructure(
|
||||
[
|
||||
@55-61 Identifier(
|
||||
"height",
|
||||
),
|
||||
@55-61 Identifier {
|
||||
ident: "height",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"f",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-20 Function(
|
||||
[
|
||||
@4-10 Tuple {
|
||||
|
|
@ -53,9 +54,10 @@ Defs(
|
|||
),
|
||||
),
|
||||
AnnotatedBody {
|
||||
ann_pattern: @0-1 Identifier(
|
||||
"f",
|
||||
),
|
||||
ann_pattern: @0-1 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
ann_type: @4-20 Function(
|
||||
[
|
||||
@4-10 Tuple {
|
||||
|
|
@ -89,14 +91,16 @@ Defs(
|
|||
},
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @21-22 Identifier(
|
||||
"f",
|
||||
),
|
||||
body_pattern: @21-22 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
body_expr: @25-32 Closure(
|
||||
[
|
||||
@26-27 Identifier(
|
||||
"x",
|
||||
),
|
||||
@26-27 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@31-32 Var {
|
||||
module_name: "",
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"f",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-21 Function(
|
||||
[
|
||||
@4-7 Apply(
|
||||
|
|
@ -45,9 +46,10 @@ Defs(
|
|||
),
|
||||
),
|
||||
AnnotatedBody {
|
||||
ann_pattern: @0-1 Identifier(
|
||||
"f",
|
||||
),
|
||||
ann_pattern: @0-1 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
ann_type: @4-21 Function(
|
||||
[
|
||||
@4-7 Apply(
|
||||
|
|
@ -73,14 +75,16 @@ Defs(
|
|||
},
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @22-23 Identifier(
|
||||
"f",
|
||||
),
|
||||
body_pattern: @22-23 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
body_expr: @26-42 Closure(
|
||||
[
|
||||
@27-28 Identifier(
|
||||
"x",
|
||||
),
|
||||
@27-28 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@32-42 Tuple(
|
||||
[
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-4 Identifier(
|
||||
"iffy",
|
||||
),
|
||||
@0-4 Identifier {
|
||||
ident: "iffy",
|
||||
suffixed: 0,
|
||||
},
|
||||
@5-6 Num(
|
||||
"5",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -37,9 +37,10 @@ BinOps(
|
|||
[
|
||||
@37-54 Closure(
|
||||
[
|
||||
@38-42 Identifier(
|
||||
"byte",
|
||||
),
|
||||
@38-42 Identifier {
|
||||
ident: "byte",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@46-54 BinOps(
|
||||
[
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
Closure(
|
||||
[
|
||||
@1-2 Identifier(
|
||||
"x",
|
||||
),
|
||||
@1-2 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@8-9 SpaceBefore(
|
||||
Num(
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-6 Identifier(
|
||||
"myList",
|
||||
),
|
||||
@0-6 Identifier {
|
||||
ident: "myList",
|
||||
suffixed: 0,
|
||||
},
|
||||
@9-57 List(
|
||||
Collection {
|
||||
items: [
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-6 Identifier(
|
||||
"myList",
|
||||
),
|
||||
@0-6 Identifier {
|
||||
ident: "myList",
|
||||
suffixed: 0,
|
||||
},
|
||||
@9-25 List(
|
||||
[
|
||||
@15-16 SpaceBefore(
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-6 Identifier(
|
||||
"myList",
|
||||
),
|
||||
@0-6 Identifier {
|
||||
ident: "myList",
|
||||
suffixed: 0,
|
||||
},
|
||||
@9-26 List(
|
||||
Collection {
|
||||
items: [
|
||||
|
|
|
|||
|
|
@ -73,18 +73,22 @@ When(
|
|||
@60-72 SpaceBefore(
|
||||
List(
|
||||
[
|
||||
@61-62 Identifier(
|
||||
"a",
|
||||
),
|
||||
@64-65 Identifier(
|
||||
"b",
|
||||
),
|
||||
@67-68 Identifier(
|
||||
"c",
|
||||
),
|
||||
@70-71 Identifier(
|
||||
"d",
|
||||
),
|
||||
@61-62 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@64-65 Identifier {
|
||||
ident: "b",
|
||||
suffixed: 0,
|
||||
},
|
||||
@67-68 Identifier {
|
||||
ident: "c",
|
||||
suffixed: 0,
|
||||
},
|
||||
@70-71 Identifier {
|
||||
ident: "d",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
[
|
||||
|
|
@ -102,12 +106,14 @@ When(
|
|||
@81-91 SpaceBefore(
|
||||
List(
|
||||
[
|
||||
@82-83 Identifier(
|
||||
"a",
|
||||
),
|
||||
@85-86 Identifier(
|
||||
"b",
|
||||
),
|
||||
@82-83 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@85-86 Identifier {
|
||||
ident: "b",
|
||||
suffixed: 0,
|
||||
},
|
||||
@88-90 ListRest(
|
||||
None,
|
||||
),
|
||||
|
|
@ -131,12 +137,14 @@ When(
|
|||
@101-103 ListRest(
|
||||
None,
|
||||
),
|
||||
@105-106 Identifier(
|
||||
"c",
|
||||
),
|
||||
@108-109 Identifier(
|
||||
"d",
|
||||
),
|
||||
@105-106 Identifier {
|
||||
ident: "c",
|
||||
suffixed: 0,
|
||||
},
|
||||
@108-109 Identifier {
|
||||
ident: "d",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
[
|
||||
|
|
@ -170,9 +178,10 @@ When(
|
|||
),
|
||||
@131-134 List(
|
||||
[
|
||||
@132-133 Identifier(
|
||||
"a",
|
||||
),
|
||||
@132-133 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
@ -207,9 +216,10 @@ When(
|
|||
@156-158 List(
|
||||
[],
|
||||
),
|
||||
@160-161 Identifier(
|
||||
"x",
|
||||
),
|
||||
@160-161 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ SpaceBefore(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@113-114 Identifier(
|
||||
"x",
|
||||
),
|
||||
@113-114 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@117-118 Num(
|
||||
"5",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@ Defs {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-4 Identifier(
|
||||
"main",
|
||||
),
|
||||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
suffixed: 0,
|
||||
},
|
||||
@11-24 SpaceBefore(
|
||||
Defs(
|
||||
Defs {
|
||||
|
|
@ -37,9 +38,10 @@ Defs {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@11-12 Identifier(
|
||||
"i",
|
||||
),
|
||||
@11-12 Identifier {
|
||||
ident: "i",
|
||||
suffixed: 0,
|
||||
},
|
||||
@15-17 Num(
|
||||
"64",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
Backpassing(
|
||||
[
|
||||
@0-1 Identifier(
|
||||
"x",
|
||||
),
|
||||
@3-4 Identifier(
|
||||
"y",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@3-4 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@8-23 Apply(
|
||||
@8-17 Var {
|
||||
|
|
|
|||
|
|
@ -15,18 +15,21 @@ Defs {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-4 Identifier(
|
||||
"main",
|
||||
),
|
||||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
suffixed: 0,
|
||||
},
|
||||
@12-50 SpaceBefore(
|
||||
Backpassing(
|
||||
[
|
||||
@12-16 Identifier(
|
||||
"arg1",
|
||||
),
|
||||
@18-22 Identifier(
|
||||
"arg2",
|
||||
),
|
||||
@12-16 Identifier {
|
||||
ident: "arg1",
|
||||
suffixed: 0,
|
||||
},
|
||||
@18-22 Identifier {
|
||||
ident: "arg2",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@26-30 Apply(
|
||||
@26-27 Var {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,10 @@ Backpassing(
|
|||
),
|
||||
],
|
||||
),
|
||||
@5-6 Identifier(
|
||||
"r",
|
||||
),
|
||||
@5-6 Identifier {
|
||||
ident: "r",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@10-11 Var {
|
||||
module_name: "",
|
||||
|
|
|
|||
|
|
@ -27,9 +27,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-1 Identifier(
|
||||
"a",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-22 Str(
|
||||
Line(
|
||||
[
|
||||
|
|
@ -50,9 +51,10 @@ Defs(
|
|||
),
|
||||
),
|
||||
Body(
|
||||
@23-24 Identifier(
|
||||
"b",
|
||||
),
|
||||
@23-24 Identifier {
|
||||
ident: "b",
|
||||
suffixed: 0,
|
||||
},
|
||||
@27-49 Str(
|
||||
Block(
|
||||
[
|
||||
|
|
@ -75,9 +77,10 @@ Defs(
|
|||
),
|
||||
),
|
||||
Body(
|
||||
@50-51 Identifier(
|
||||
"c",
|
||||
),
|
||||
@50-51 Identifier {
|
||||
ident: "c",
|
||||
suffixed: 0,
|
||||
},
|
||||
@58-92 SpaceBefore(
|
||||
Str(
|
||||
Block(
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"f",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
@8-10 SpaceBefore(
|
||||
Record {
|
||||
fields: [],
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"f",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
@17-19 SpaceBefore(
|
||||
Record {
|
||||
fields: [],
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-1 Identifier(
|
||||
"a",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@2-9 Apply(
|
||||
@2-3 SpaceAfter(
|
||||
Tag(
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-4 Identifier(
|
||||
"main",
|
||||
),
|
||||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
suffixed: 0,
|
||||
},
|
||||
@11-71 SpaceBefore(
|
||||
Defs(
|
||||
Defs {
|
||||
|
|
@ -38,14 +39,16 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@11-15 Identifier(
|
||||
"task",
|
||||
),
|
||||
@11-15 Identifier {
|
||||
ident: "task",
|
||||
suffixed: 0,
|
||||
},
|
||||
@18-62 Backpassing(
|
||||
[
|
||||
@18-22 Identifier(
|
||||
"file",
|
||||
),
|
||||
@18-22 Identifier {
|
||||
ident: "file",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@43-46 SpaceBefore(
|
||||
Var {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@ Defs {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-4 Identifier(
|
||||
"main",
|
||||
),
|
||||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
suffixed: 0,
|
||||
},
|
||||
@11-115 SpaceBefore(
|
||||
Defs(
|
||||
Defs {
|
||||
|
|
@ -37,9 +38,10 @@ Defs {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@11-23 Identifier(
|
||||
"wrappedNotEq",
|
||||
),
|
||||
@11-23 Identifier {
|
||||
ident: "wrappedNotEq",
|
||||
suffixed: 0,
|
||||
},
|
||||
@26-38 Function(
|
||||
[
|
||||
@26-27 BoundVariable(
|
||||
|
|
@ -57,9 +59,10 @@ Defs {
|
|||
),
|
||||
),
|
||||
AnnotatedBody {
|
||||
ann_pattern: @11-23 Identifier(
|
||||
"wrappedNotEq",
|
||||
),
|
||||
ann_pattern: @11-23 Identifier {
|
||||
ident: "wrappedNotEq",
|
||||
suffixed: 0,
|
||||
},
|
||||
ann_type: @26-38 Function(
|
||||
[
|
||||
@26-27 BoundVariable(
|
||||
|
|
@ -76,17 +79,20 @@ Defs {
|
|||
),
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @43-55 Identifier(
|
||||
"wrappedNotEq",
|
||||
),
|
||||
body_pattern: @43-55 Identifier {
|
||||
ident: "wrappedNotEq",
|
||||
suffixed: 0,
|
||||
},
|
||||
body_expr: @58-93 Closure(
|
||||
[
|
||||
@59-63 Identifier(
|
||||
"num1",
|
||||
),
|
||||
@65-69 Identifier(
|
||||
"num2",
|
||||
),
|
||||
@59-63 Identifier {
|
||||
ident: "num1",
|
||||
suffixed: 0,
|
||||
},
|
||||
@65-69 Identifier {
|
||||
ident: "num2",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@81-93 SpaceBefore(
|
||||
BinOps(
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-1 Identifier(
|
||||
"x",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@2-7 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
|
|
@ -37,9 +38,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@2-3 Identifier(
|
||||
"a",
|
||||
),
|
||||
@2-3 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-5 BoundVariable(
|
||||
"n",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-1 Identifier(
|
||||
"x",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@8-9 SpaceBefore(
|
||||
Num(
|
||||
"5",
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-1 Identifier(
|
||||
"x",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-13 BinOps(
|
||||
[
|
||||
(
|
||||
|
|
|
|||
|
|
@ -100,9 +100,10 @@ Full {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@199-203 Identifier(
|
||||
"main",
|
||||
),
|
||||
@199-203 Identifier {
|
||||
ident: "main",
|
||||
suffixed: 0,
|
||||
},
|
||||
@210-246 SpaceBefore(
|
||||
Apply(
|
||||
@210-221 Var {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
SpaceBefore(
|
||||
Backpassing(
|
||||
[
|
||||
@18-19 Identifier(
|
||||
"x",
|
||||
),
|
||||
@18-19 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@23-32 ParensAround(
|
||||
Closure(
|
||||
[
|
||||
@25-26 Identifier(
|
||||
"y",
|
||||
),
|
||||
@25-26 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@30-31 Var {
|
||||
module_name: "",
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ SpaceBefore(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@18-19 Identifier(
|
||||
"x",
|
||||
),
|
||||
@18-19 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@20-21 Num(
|
||||
"5",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ SpaceBefore(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@18-19 Identifier(
|
||||
"x",
|
||||
),
|
||||
@18-19 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@22-23 Num(
|
||||
"5",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@ Defs(
|
|||
"@Thunk",
|
||||
),
|
||||
[
|
||||
@7-9 Identifier(
|
||||
"it",
|
||||
),
|
||||
@7-9 Identifier {
|
||||
ident: "it",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
@12-22 Apply(
|
||||
|
|
|
|||
|
|
@ -13,12 +13,14 @@ When(
|
|||
"@Add",
|
||||
),
|
||||
[
|
||||
@17-18 Identifier(
|
||||
"n",
|
||||
),
|
||||
@19-20 Identifier(
|
||||
"m",
|
||||
),
|
||||
@17-18 Identifier {
|
||||
ident: "n",
|
||||
suffixed: 0,
|
||||
},
|
||||
@19-20 Identifier {
|
||||
ident: "m",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
[
|
||||
|
|
|
|||
|
|
@ -38,9 +38,10 @@ Defs(
|
|||
],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"a",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@2-3 BoundVariable(
|
||||
"e",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ Defs {
|
|||
header: TypeHeader {
|
||||
name: @0-10 "Bookmark",
|
||||
vars: [
|
||||
@9-10 Identifier(
|
||||
"a",
|
||||
),
|
||||
@9-10 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
typ: @14-53 Record {
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-1 Identifier(
|
||||
"x",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-29 Apply(
|
||||
@4-7 Var {
|
||||
module_name: "",
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-1 Identifier(
|
||||
"x",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-22 Apply(
|
||||
@4-7 Var {
|
||||
module_name: "",
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-1 Identifier(
|
||||
"a",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-17 List(
|
||||
[
|
||||
@8-9 SpaceBefore(
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-1 Identifier(
|
||||
"x",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-23 Apply(
|
||||
@4-7 Var {
|
||||
module_name: "",
|
||||
|
|
|
|||
|
|
@ -19,13 +19,15 @@ Defs(
|
|||
name: @0-1 "U",
|
||||
vars: [
|
||||
@2-5 Apply(
|
||||
@2-3 Identifier(
|
||||
"b",
|
||||
),
|
||||
@2-3 Identifier {
|
||||
ident: "b",
|
||||
suffixed: 0,
|
||||
},
|
||||
[
|
||||
@4-5 Identifier(
|
||||
"a",
|
||||
),
|
||||
@4-5 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ Defs(
|
|||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Apply(
|
||||
@0-1 Identifier(
|
||||
"i",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "i",
|
||||
suffixed: 0,
|
||||
},
|
||||
[
|
||||
@5-6 SpaceBefore(
|
||||
Tag(
|
||||
|
|
|
|||
|
|
@ -18,12 +18,14 @@ Defs(
|
|||
header: TypeHeader {
|
||||
name: @0-4 "Blah",
|
||||
vars: [
|
||||
@5-6 Identifier(
|
||||
"a",
|
||||
),
|
||||
@7-8 Identifier(
|
||||
"b",
|
||||
),
|
||||
@5-6 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@7-8 Identifier {
|
||||
ident: "b",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
ann: @11-26 Apply(
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-3 Identifier(
|
||||
"foo",
|
||||
),
|
||||
@0-3 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
@6-33 As(
|
||||
@6-21 Apply(
|
||||
"Foo.Bar",
|
||||
|
|
@ -36,12 +37,14 @@ Defs(
|
|||
TypeHeader {
|
||||
name: @25-29 "Blah",
|
||||
vars: [
|
||||
@30-31 Identifier(
|
||||
"a",
|
||||
),
|
||||
@32-33 Identifier(
|
||||
"b",
|
||||
),
|
||||
@30-31 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@32-33 Identifier {
|
||||
ident: "b",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
|
|
|
|||
|
|
@ -10,9 +10,10 @@ When(
|
|||
@19-38 SpaceBefore(
|
||||
List(
|
||||
[
|
||||
@20-25 Identifier(
|
||||
"first",
|
||||
),
|
||||
@20-25 Identifier {
|
||||
ident: "first",
|
||||
suffixed: 0,
|
||||
},
|
||||
@27-37 ListRest(
|
||||
Some(
|
||||
(
|
||||
|
|
|
|||
|
|
@ -39,9 +39,10 @@ When(
|
|||
"Del",
|
||||
),
|
||||
[
|
||||
@42-44 Identifier(
|
||||
"ry",
|
||||
),
|
||||
@42-44 Identifier {
|
||||
ident: "ry",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
@47-48 Underscore(
|
||||
|
|
|
|||
|
|
@ -25,12 +25,14 @@ SpaceBefore(
|
|||
Body(
|
||||
@18-26 RecordDestructure(
|
||||
[
|
||||
@20-21 Identifier(
|
||||
"x",
|
||||
),
|
||||
@23-25 Identifier(
|
||||
"y",
|
||||
),
|
||||
@20-21 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@23-25 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
@29-30 Num(
|
||||
|
|
@ -38,9 +40,10 @@ SpaceBefore(
|
|||
),
|
||||
),
|
||||
Body(
|
||||
@31-32 Identifier(
|
||||
"y",
|
||||
),
|
||||
@31-32 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
@35-36 Num(
|
||||
"6",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"f",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
@8-122 SpaceBefore(
|
||||
Record {
|
||||
fields: [
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"x",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-77 Record {
|
||||
fields: [
|
||||
@6-24 RequiredValue(
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
Closure(
|
||||
[
|
||||
@1-2 Identifier(
|
||||
"a",
|
||||
),
|
||||
@1-2 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@6-8 Num(
|
||||
"42",
|
||||
|
|
|
|||
|
|
@ -93,9 +93,10 @@ Full {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@98-102 Identifier(
|
||||
"main",
|
||||
),
|
||||
@98-102 Identifier {
|
||||
ident: "main",
|
||||
suffixed: 0,
|
||||
},
|
||||
@105-124 Apply(
|
||||
@105-116 Var {
|
||||
module_name: "Stdout",
|
||||
|
|
|
|||
|
|
@ -37,17 +37,19 @@ Defs {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@12-15 Identifier(
|
||||
"foo",
|
||||
),
|
||||
@12-15 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
@18-19 Num(
|
||||
"1",
|
||||
),
|
||||
),
|
||||
Body(
|
||||
@33-36 Identifier(
|
||||
"bar",
|
||||
),
|
||||
@33-36 Identifier {
|
||||
ident: "bar",
|
||||
suffixed: 0,
|
||||
},
|
||||
@39-43 Str(
|
||||
PlainLine(
|
||||
"hi",
|
||||
|
|
@ -55,9 +57,10 @@ Defs {
|
|||
),
|
||||
),
|
||||
Body(
|
||||
@44-47 Identifier(
|
||||
"baz",
|
||||
),
|
||||
@44-47 Identifier {
|
||||
ident: "baz",
|
||||
suffixed: 0,
|
||||
},
|
||||
@50-57 Str(
|
||||
PlainLine(
|
||||
"stuff",
|
||||
|
|
|
|||
|
|
@ -64,9 +64,10 @@ Defs {
|
|||
@120-131 SpaceBefore(
|
||||
Closure(
|
||||
[
|
||||
@121-122 Identifier(
|
||||
"a",
|
||||
),
|
||||
@121-122 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@126-131 BinOps(
|
||||
[
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ app "desugar-bang"
|
|||
provides [main] to cli
|
||||
|
||||
main =
|
||||
Stdout.line! "Foo"
|
||||
Stdout.line!
|
||||
"Foo"
|
||||
|
||||
"Bar"
|
||||
"Bar"
|
||||
|> Stdout.line
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ Full {
|
|||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@155-184,
|
||||
@155-215,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 2),
|
||||
|
|
@ -113,76 +113,57 @@ Full {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@155-159 Identifier(
|
||||
"main",
|
||||
),
|
||||
@155-184 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@155-184,
|
||||
],
|
||||
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 {
|
||||
@155-159 Identifier {
|
||||
ident: "main",
|
||||
suffixed: 0,
|
||||
},
|
||||
@166-215 SpaceBefore(
|
||||
BinOps(
|
||||
[
|
||||
(
|
||||
@166-195 SpaceAfter(
|
||||
Apply(
|
||||
@166-178 Var {
|
||||
module_name: "Stdout",
|
||||
ident: "line",
|
||||
suffixed: 1,
|
||||
},
|
||||
[
|
||||
@179-184 Str(
|
||||
PlainLine(
|
||||
"Foo",
|
||||
),
|
||||
),
|
||||
@190-195 SpaceBefore(
|
||||
Str(
|
||||
PlainLine(
|
||||
"Bar",
|
||||
),
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
[
|
||||
@179-184 Str(
|
||||
PlainLine(
|
||||
"Foo",
|
||||
),
|
||||
),
|
||||
Newline,
|
||||
],
|
||||
Space,
|
||||
),
|
||||
@201-203 Pizza,
|
||||
),
|
||||
],
|
||||
},
|
||||
@190-215 SpaceBefore(
|
||||
BinOps(
|
||||
[
|
||||
(
|
||||
@190-195 SpaceAfter(
|
||||
Str(
|
||||
PlainLine(
|
||||
"Bar",
|
||||
),
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
@201-203 Pizza,
|
||||
),
|
||||
],
|
||||
@204-215 Var {
|
||||
module_name: "Stdout",
|
||||
ident: "line",
|
||||
},
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
Newline,
|
||||
],
|
||||
@204-215 Var {
|
||||
module_name: "Stdout",
|
||||
ident: "line",
|
||||
suffixed: 0,
|
||||
},
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -95,9 +95,10 @@ Full {
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@88-92 Identifier(
|
||||
"main",
|
||||
),
|
||||
@88-92 Identifier {
|
||||
ident: "main",
|
||||
suffixed: 0,
|
||||
},
|
||||
@100-202 SpaceBefore(
|
||||
BinOps(
|
||||
[
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
Closure(
|
||||
[
|
||||
@1-2 Identifier(
|
||||
"a",
|
||||
),
|
||||
@4-5 Identifier(
|
||||
"b",
|
||||
),
|
||||
@7-8 Identifier(
|
||||
"c",
|
||||
),
|
||||
@1-2 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-5 Identifier {
|
||||
ident: "b",
|
||||
suffixed: 0,
|
||||
},
|
||||
@7-8 Identifier {
|
||||
ident: "c",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@12-14 Num(
|
||||
"42",
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-3 Identifier(
|
||||
"abc",
|
||||
),
|
||||
@0-3 Identifier {
|
||||
ident: "abc",
|
||||
suffixed: 0,
|
||||
},
|
||||
@6-15 Tuple(
|
||||
[
|
||||
@7-8 Num(
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"f",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
@3-27 Function(
|
||||
[
|
||||
@3-13 Tuple {
|
||||
|
|
@ -55,9 +56,10 @@ Defs(
|
|||
),
|
||||
),
|
||||
AnnotatedBody {
|
||||
ann_pattern: @0-1 Identifier(
|
||||
"f",
|
||||
),
|
||||
ann_pattern: @0-1 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
ann_type: @3-27 Function(
|
||||
[
|
||||
@3-13 Tuple {
|
||||
|
|
@ -93,14 +95,16 @@ Defs(
|
|||
},
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @28-29 Identifier(
|
||||
"f",
|
||||
),
|
||||
body_pattern: @28-29 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
body_expr: @32-39 Closure(
|
||||
[
|
||||
@33-34 Identifier(
|
||||
"x",
|
||||
),
|
||||
@33-34 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@38-39 Var {
|
||||
module_name: "",
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"f",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
@3-29 Function(
|
||||
[
|
||||
@3-14 Tuple {
|
||||
|
|
@ -63,9 +64,10 @@ Defs(
|
|||
),
|
||||
),
|
||||
AnnotatedBody {
|
||||
ann_pattern: @0-1 Identifier(
|
||||
"f",
|
||||
),
|
||||
ann_pattern: @0-1 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
ann_type: @3-29 Function(
|
||||
[
|
||||
@3-14 Tuple {
|
||||
|
|
@ -109,14 +111,16 @@ Defs(
|
|||
},
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @30-31 Identifier(
|
||||
"f",
|
||||
),
|
||||
body_pattern: @30-31 Identifier {
|
||||
ident: "f",
|
||||
suffixed: 0,
|
||||
},
|
||||
body_expr: @34-41 Closure(
|
||||
[
|
||||
@35-36 Identifier(
|
||||
"x",
|
||||
),
|
||||
@35-36 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@40-41 Var {
|
||||
module_name: "",
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
Closure(
|
||||
[
|
||||
@1-2 Identifier(
|
||||
"a",
|
||||
),
|
||||
@4-5 Identifier(
|
||||
"b",
|
||||
),
|
||||
@1-2 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-5 Identifier {
|
||||
ident: "b",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@9-11 Num(
|
||||
"42",
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
SpaceBefore(
|
||||
Backpassing(
|
||||
[
|
||||
@18-19 Identifier(
|
||||
"x",
|
||||
),
|
||||
@18-19 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@23-32 ParensAround(
|
||||
Closure(
|
||||
[
|
||||
@25-26 Identifier(
|
||||
"y",
|
||||
),
|
||||
@25-26 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@30-31 Var {
|
||||
module_name: "",
|
||||
|
|
@ -22,9 +24,10 @@ SpaceBefore(
|
|||
@33-43 SpaceBefore(
|
||||
Backpassing(
|
||||
[
|
||||
@33-34 Identifier(
|
||||
"z",
|
||||
),
|
||||
@33-34 Identifier {
|
||||
ident: "z",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@38-40 Record(
|
||||
[],
|
||||
|
|
|
|||
|
|
@ -23,17 +23,19 @@ SpaceBefore(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@18-19 Identifier(
|
||||
"x",
|
||||
),
|
||||
@18-19 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@22-23 Num(
|
||||
"5",
|
||||
),
|
||||
),
|
||||
Body(
|
||||
@24-25 Identifier(
|
||||
"y",
|
||||
),
|
||||
@24-25 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
@28-29 Num(
|
||||
"6",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-7 Identifier(
|
||||
"doStuff",
|
||||
),
|
||||
@0-7 Identifier {
|
||||
ident: "doStuff",
|
||||
suffixed: 0,
|
||||
},
|
||||
@10-30 Function(
|
||||
[
|
||||
@10-16 Apply(
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-3 Identifier(
|
||||
"foo",
|
||||
),
|
||||
@0-3 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
@6-9 Apply(
|
||||
"",
|
||||
"Int",
|
||||
|
|
@ -26,18 +27,20 @@ Defs(
|
|||
),
|
||||
),
|
||||
AnnotatedBody {
|
||||
ann_pattern: @0-3 Identifier(
|
||||
"foo",
|
||||
),
|
||||
ann_pattern: @0-3 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
ann_type: @6-9 Apply(
|
||||
"",
|
||||
"Int",
|
||||
[],
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @10-13 Identifier(
|
||||
"foo",
|
||||
),
|
||||
body_pattern: @10-13 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
body_expr: @16-17 Num(
|
||||
"4",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-3 Identifier(
|
||||
"foo",
|
||||
),
|
||||
@0-3 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
@6-24 Function(
|
||||
[
|
||||
@6-9 Apply(
|
||||
|
|
@ -40,9 +41,10 @@ Defs(
|
|||
),
|
||||
),
|
||||
AnnotatedBody {
|
||||
ann_pattern: @0-3 Identifier(
|
||||
"foo",
|
||||
),
|
||||
ann_pattern: @0-3 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
ann_type: @6-24 Function(
|
||||
[
|
||||
@6-9 Apply(
|
||||
|
|
@ -63,14 +65,16 @@ Defs(
|
|||
),
|
||||
),
|
||||
comment: None,
|
||||
body_pattern: @25-28 Identifier(
|
||||
"foo",
|
||||
),
|
||||
body_pattern: @25-28 Identifier {
|
||||
ident: "foo",
|
||||
suffixed: 0,
|
||||
},
|
||||
body_expr: @31-42 Closure(
|
||||
[
|
||||
@32-33 Identifier(
|
||||
"x",
|
||||
),
|
||||
@32-33 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@35-36 Underscore(
|
||||
"",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@ SpaceBefore(
|
|||
@23-32 ParensAround(
|
||||
Closure(
|
||||
[
|
||||
@25-26 Identifier(
|
||||
"y",
|
||||
),
|
||||
@25-26 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@30-31 Var {
|
||||
module_name: "",
|
||||
|
|
|
|||
|
|
@ -42,9 +42,10 @@ Defs(
|
|||
"Pair",
|
||||
),
|
||||
[
|
||||
@5-6 Identifier(
|
||||
"x",
|
||||
),
|
||||
@5-6 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@7-8 Underscore(
|
||||
"",
|
||||
),
|
||||
|
|
@ -74,9 +75,10 @@ Defs(
|
|||
@25-26 Underscore(
|
||||
"",
|
||||
),
|
||||
@27-28 Identifier(
|
||||
"y",
|
||||
),
|
||||
@27-28 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
@31-39 Apply(
|
||||
|
|
@ -153,9 +155,10 @@ Defs(
|
|||
"Pair",
|
||||
),
|
||||
[
|
||||
@84-85 Identifier(
|
||||
"x",
|
||||
),
|
||||
@84-85 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@86-87 Underscore(
|
||||
"",
|
||||
),
|
||||
|
|
@ -169,9 +172,10 @@ Defs(
|
|||
@95-96 Underscore(
|
||||
"",
|
||||
),
|
||||
@97-98 Identifier(
|
||||
"y",
|
||||
),
|
||||
@97-98 Identifier {
|
||||
ident: "y",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -32,9 +32,10 @@ Defs(
|
|||
],
|
||||
value_defs: [
|
||||
Annotation(
|
||||
@0-1 Identifier(
|
||||
"a",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "a",
|
||||
suffixed: 0,
|
||||
},
|
||||
@2-3 Apply(
|
||||
"",
|
||||
"F",
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-1 Identifier(
|
||||
"x",
|
||||
),
|
||||
@0-1 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
@4-25 When(
|
||||
@9-10 Var {
|
||||
module_name: "",
|
||||
|
|
|
|||
|
|
@ -16,14 +16,16 @@ Defs(
|
|||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-4 Identifier(
|
||||
"func",
|
||||
),
|
||||
@0-4 Identifier {
|
||||
ident: "func",
|
||||
suffixed: 0,
|
||||
},
|
||||
@7-43 Closure(
|
||||
[
|
||||
@8-9 Identifier(
|
||||
"x",
|
||||
),
|
||||
@8-9 Identifier {
|
||||
ident: "x",
|
||||
suffixed: 0,
|
||||
},
|
||||
],
|
||||
@13-43 When(
|
||||
@18-19 Var {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue