cleanup, improve docs

This commit is contained in:
Luke Boswell 2024-04-12 15:10:16 +10:00
parent c32fa5b600
commit 0143035dc0
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
8 changed files with 42 additions and 60 deletions

View file

@ -495,12 +495,6 @@ pub fn desugar_expr<'a>(
desugar_defs_node_values(arena, &mut defs, src, line_info, module_path, false);
let loc_ret = desugar_expr(arena, loc_ret, src, line_info, module_path);
// Desugar any suffixed nodes, such as `foo = bar!`
// desugar_defs_node_suffixed(
// arena,
// arena.alloc(Loc::at(loc_expr.region, Defs(arena.alloc(defs), loc_ret))),
// )
arena.alloc(Loc::at(loc_expr.region, Defs(arena.alloc(defs), loc_ret)))
}
Apply(loc_fn, loc_args, called_via) => {
@ -683,15 +677,6 @@ pub fn desugar_expr<'a>(
value: If(desugared_if_thens.into_bump_slice(), desugared_final_else),
region: loc_expr.region,
})
// Desugar any suffixed nodes, such as `if isTrue! then ...`
// desugar_if_node_suffixed(
// arena,
// arena.alloc(Loc {
// value: If(desugared_if_thens.into_bump_slice(), desugared_final_else),
// region: loc_expr.region,
// }),
// )
}
Expect(condition, continuation) => {
let desugared_condition =

View file

@ -312,9 +312,6 @@ pub fn canonicalize_module_defs<'a>(
// visited a BinOp node we'd recursively try to apply this to each of its nested
// operators, and then again on *their* nested operators, ultimately applying the
// rules multiple times unnecessarily.
// if module_path.contains("test.roc"){
// dbg!(&loc_defs);
// }
crate::desugar::desugar_defs_node_values(arena, loc_defs, src, &mut None, module_path, true);

View file

@ -265,7 +265,6 @@ 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.
// TODO should we use suffixed here?
Identifier {
ident: name,
suffixed: _,
@ -377,7 +376,6 @@ pub fn canonicalize_pattern<'a>(
use PatternType::*;
let can_pattern = match pattern {
// TODO do we need to use suffixed here?
Identifier {
ident: name,
suffixed: _,
@ -634,7 +632,6 @@ pub fn canonicalize_pattern<'a>(
for loc_pattern in patterns.iter() {
match loc_pattern.value {
// TODO should we use suffixed here?
Identifier {
ident: label,
suffixed: _,

View file

@ -128,7 +128,7 @@ pub fn unwrap_suffixed_expression<'a>(
},
));
// we generate an intermedite pattern `#!a0` etc
// we generate an intermediate pattern `#!a0` etc
// so we dont unwrap the definition pattern
let (mut answer_var, answer_pat) = next_suffixed_answer_pattern(arena);
@ -363,6 +363,9 @@ pub fn unwrap_suffixed_expression_if_then_else_help<'a>(
) -> Result<&'a Loc<Expr<'a>>, EUnwrapped<'a>> {
Ok(loc_expr)
// TODO - the logic below is mostly correct, however it needs to be
// translated to this new method and tests added, leaving this for a future PR
// consider each if-statement, if it is suffixed we need to desugar e.g.
// ```
// if isFalse! then