diff --git a/crates/compiler/DESIGN.md b/crates/compiler/DESIGN.md index be77a57225f..3db6125cba8 100644 --- a/crates/compiler/DESIGN.md +++ b/crates/compiler/DESIGN.md @@ -87,8 +87,7 @@ program. Among other things, canonicalization solving. - Determines the order definitions are used in, if they are defined out-of-order. -- Eliminates syntax sugar (for example, renaming `+` to the function call `add` - and converting backpassing to function calls). +- Eliminates syntax sugar (for example, renaming `+` to the function call `add`). - Collects declared abilities, and ability implementations defined for opaque types. Derived abilities for opaque types are elaborated during canonicalization. diff --git a/crates/compiler/can/src/desugar.rs b/crates/compiler/can/src/desugar.rs index 8786ad9bf66..5ba9ede2b64 100644 --- a/crates/compiler/can/src/desugar.rs +++ b/crates/compiler/can/src/desugar.rs @@ -734,50 +734,6 @@ pub fn desugar_expr<'a>( desugar_expr(env, scope, loc_ret), ), }), - Backpassing(loc_patterns, loc_body, loc_ret) => { - // loc_patterns <- loc_body - // - // loc_ret - - let problem_region = Region::span_across( - &Region::across_all(loc_patterns.iter().map(|loc_pattern| &loc_pattern.region)), - &loc_body.region, - ); - env.problem(Problem::DeprecatedBackpassing(problem_region)); - - // first desugar the body, because it may contain |> - let desugared_body = desugar_expr(env, scope, loc_body); - - let desugared_ret = desugar_expr(env, scope, loc_ret); - let desugared_loc_patterns = desugar_loc_patterns(env, scope, loc_patterns); - let closure = Expr::Closure(desugared_loc_patterns, desugared_ret); - let loc_closure = Loc::at(loc_expr.region, closure); - - match &desugared_body.value { - Expr::Apply(function, arguments, called_via) => { - let mut new_arguments: Vec<'a, &'a Loc>> = - Vec::with_capacity_in(arguments.len() + 1, env.arena); - new_arguments.extend(arguments.iter()); - new_arguments.push(env.arena.alloc(loc_closure)); - - let call = Expr::Apply(function, new_arguments.into_bump_slice(), *called_via); - let loc_call = Loc::at(loc_expr.region, call); - - env.arena.alloc(loc_call) - } - _ => { - // e.g. `x <- (if b then (\a -> a) else (\c -> c))` - let call = Expr::Apply( - desugared_body, - env.arena.alloc([&*env.arena.alloc(loc_closure)]), - CalledVia::Space, - ); - let loc_call = Loc::at(loc_expr.region, call); - - env.arena.alloc(loc_call) - } - } - } RecordBuilder { mapper, fields } => { // NOTE the `mapper` is always a `Var { .. }`, we only desugar it to get rid of // any spaces before/after diff --git a/crates/compiler/can/src/expr.rs b/crates/compiler/can/src/expr.rs index 555b7576fb5..2fca79eb266 100644 --- a/crates/compiler/can/src/expr.rs +++ b/crates/compiler/can/src/expr.rs @@ -1148,9 +1148,6 @@ pub fn canonicalize_expr<'a>( ast::Expr::RecordBuilder { .. } => { internal_error!("Record builder should have been desugared by now") } - ast::Expr::Backpassing(_, _, _) => { - internal_error!("Backpassing should have been desugared by now") - } ast::Expr::RecordUpdater(_) => { internal_error!("Record updater should have been desugared by now") } @@ -2219,7 +2216,6 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool { | ast::Expr::LowLevelDbg(_, _, _) | ast::Expr::Return(_, _) | ast::Expr::When(_, _) - | ast::Expr::Backpassing(_, _, _) | ast::Expr::SpaceBefore(_, _) | ast::Expr::Str(StrLiteral::Block(_)) | ast::Expr::SpaceAfter(_, _) => false, diff --git a/crates/compiler/fmt/src/def.rs b/crates/compiler/fmt/src/def.rs index 4c7868ca821..eefab0bc61b 100644 --- a/crates/compiler/fmt/src/def.rs +++ b/crates/compiler/fmt/src/def.rs @@ -1039,7 +1039,6 @@ pub fn fmt_body<'a>( && pattern_extracted.after.iter().all(|s| s.is_newline()) && !matches!(body.extract_spaces().item, Expr::Defs(..)) && !matches!(body.extract_spaces().item, Expr::Return(..)) - && !matches!(body.extract_spaces().item, Expr::Backpassing(..)) && !matches!(body.extract_spaces().item, Expr::DbgStmt { .. }) && !starts_with_expect_ident(body) } else { @@ -1116,7 +1115,7 @@ pub fn fmt_body<'a>( buf.ensure_ends_with_newline(); body.format_with_options(buf, Parens::NotNeeded, Newlines::Yes, indent + INDENT); } - Expr::Defs(..) | Expr::BinOps(_, _) | Expr::Backpassing(..) => { + Expr::Defs(..) | Expr::BinOps(_, _) => { // Binop chains always get a newline. Otherwise you can have things like: // // something = foo diff --git a/crates/compiler/fmt/src/expr.rs b/crates/compiler/fmt/src/expr.rs index 21b6a5fccbe..5384cb73739 100644 --- a/crates/compiler/fmt/src/expr.rs +++ b/crates/compiler/fmt/src/expr.rs @@ -2,8 +2,7 @@ use crate::annotation::{except_last, is_collection_multiline, Formattable, Newli use crate::collection::{fmt_collection, Braces}; use crate::def::{fmt_defs, valdef_lift_spaces_before}; use crate::pattern::{ - fmt_pattern, pattern_lift_spaces, pattern_lift_spaces_before, snakify_camel_ident, - starts_with_inline_comment, + fmt_pattern, pattern_lift_spaces, snakify_camel_ident, starts_with_inline_comment, }; use crate::spaces::{ count_leading_newlines, fmt_comments_only, fmt_spaces, fmt_spaces_no_blank_lines, @@ -166,9 +165,6 @@ fn format_expr_only( Expr::Closure(loc_patterns, loc_ret) => { fmt_closure(buf, loc_patterns, loc_ret, indent); } - Expr::Backpassing(loc_patterns, loc_body, loc_ret) => { - fmt_backpassing(buf, loc_patterns, loc_body, loc_ret, indent); - } Expr::Defs(defs, ret) => { let defs_needs_parens = parens == Parens::InOperator || parens == Parens::InApply; @@ -566,14 +562,6 @@ pub fn expr_is_multiline(me: &Expr<'_>, comments_only: bool) -> bool { .iter() .any(|loc_pattern| loc_pattern.value.is_multiline()) } - Expr::Backpassing(loc_patterns, loc_body, loc_ret) => { - // check the body first because it's more likely to be multiline - expr_is_multiline(&loc_body.value, comments_only) - || expr_is_multiline(&loc_ret.value, comments_only) - || loc_patterns - .iter() - .any(|loc_pattern| loc_pattern.value.is_multiline()) - } Expr::Record(fields) => is_collection_multiline(fields), Expr::Tuple(fields) => is_collection_multiline(fields), @@ -1225,37 +1213,6 @@ pub fn expr_lift_spaces<'a, 'b: 'a>( } } } - Expr::Backpassing(pats, call, continuation) => { - let pats = arena.alloc_slice_copy(pats); - let before = if let Some(first) = pats.first_mut() { - let lifted = pattern_lift_spaces_before(arena, &first.value); - *first = Loc::at(first.region, lifted.item); - lifted.before - } else { - &[] - }; - let continuation_lifted = - expr_lift_spaces_after(Parens::NotNeeded, arena, &continuation.value); - - let mut res = Spaces { - before, - item: Expr::Backpassing( - pats, - call, - arena.alloc(Loc::at(continuation.region, continuation_lifted.item)), - ), - after: continuation_lifted.after, - }; - - if parens == Parens::InApply || parens == Parens::InApplyLastArg { - res = Spaces { - before: &[], - item: Expr::ParensAround(arena.alloc(lower(arena, res))), - after: &[], - }; - } - res - } Expr::SpaceBefore(expr, spaces) => { let mut inner = expr_lift_spaces(parens, arena, expr); inner.before = merge_spaces_conservative(arena, spaces, inner.before); @@ -1825,7 +1782,7 @@ fn fmt_return<'a>( format_spaces(buf, value.before, newlines, return_indent); } - if matches!(value.item, Expr::Defs(..) | Expr::Backpassing(..)) { + if matches!(value.item, Expr::Defs(..)) { buf.ensure_ends_with_newline(); } else { buf.spaces(1); @@ -2025,124 +1982,6 @@ fn fmt_closure<'a>( } } -fn fmt_backpassing<'a>( - buf: &mut Buf, - loc_patterns: &'a [Loc>], - loc_body: &'a Loc>, - loc_ret: &'a Loc>, - outer_indent: u16, -) { - let arguments_are_multiline = loc_patterns - .iter() - .any(|loc_pattern| loc_pattern.is_multiline()); - - // If the arguments are multiline, go down a line and indent. - let arg_indent = if arguments_are_multiline { - outer_indent + INDENT - } else { - outer_indent - }; - - let mut first = true; - - for loc_pattern in loc_patterns.iter() { - let needs_parens = if pattern_needs_parens_when_backpassing(&loc_pattern.value) { - Parens::InApply - } else { - Parens::NotNeeded - }; - - let pat = pattern_lift_spaces(buf.text.bump(), &loc_pattern.value); - - if !first { - buf.indent(arg_indent); - buf.push(','); - } - - fmt_comments_only(buf, pat.before.iter(), NewlineAt::Bottom, arg_indent); - - if !first { - if arguments_are_multiline { - buf.ensure_ends_with_newline(); - } else { - buf.spaces(1); - } - } - - pat.item.format_with_options( - buf, - needs_parens, - Newlines::No, - if first { outer_indent } else { arg_indent }, - ); - fmt_comments_only(buf, pat.after.iter(), NewlineAt::Bottom, arg_indent); - - first = false; - } - - if arguments_are_multiline { - buf.ensure_ends_with_newline(); - buf.indent(arg_indent); - } else { - buf.spaces(1); - } - - buf.push_str("<-"); - - let is_multiline = loc_ret.value.is_multiline(); - - // If the body is multiline, go down a line and indent. - let body_indent = if is_multiline { - arg_indent + INDENT - } else { - arg_indent - }; - - buf.spaces(1); - let body_lifted = expr_lift_spaces(Parens::NotNeeded, buf.text.bump(), &loc_body.value); - let ret_lifted = expr_lift_spaces(Parens::NotNeeded, buf.text.bump(), &loc_ret.value); - - if !body_lifted.before.is_empty() { - format_spaces(buf, body_lifted.before, Newlines::Yes, body_indent); - } - - format_expr_only( - &body_lifted.item, - buf, - Parens::NotNeeded, - Newlines::Yes, - body_indent, - ); - - let between = merge_spaces(buf.text.bump(), body_lifted.after, ret_lifted.before); - - if !between.is_empty() { - format_spaces(buf, between, Newlines::Yes, outer_indent); - } - - format_expr_only( - &ret_lifted.item, - buf, - Parens::NotNeeded, - Newlines::Yes, - outer_indent, - ); - - if !ret_lifted.after.is_empty() { - format_spaces(buf, ret_lifted.after, Newlines::Yes, outer_indent); - } -} - -fn pattern_needs_parens_when_backpassing(pat: &Pattern) -> bool { - match pat { - Pattern::Apply(_, _) => true, - Pattern::SpaceBefore(a, _) | Pattern::SpaceAfter(a, _) => { - pattern_needs_parens_when_backpassing(a) - } - _ => false, - } -} - enum RecordPrefix<'a> { Update(&'a Loc>), Mapper(&'a Loc>), @@ -2321,7 +2160,7 @@ pub fn sub_expr_requests_parens(expr: &Expr<'_>) -> bool { } Expr::If { .. } => true, Expr::Defs(_, _) => true, - Expr::Return(..) | Expr::Backpassing(..) | Expr::DbgStmt { .. } => { + Expr::Return(..) | Expr::DbgStmt { .. } => { // This is because e.g. (return x)\nfoo would be de-parenthesized and cause the `after_return` to be `foo`. // That _is_ a semantic change technically right now, because that transform is done in the parser. // When that's moved to `can`, we can remove this diff --git a/crates/compiler/load/tests/test_reporting.rs b/crates/compiler/load/tests/test_reporting.rs index ca7be764429..6b1e9a79d51 100644 --- a/crates/compiler/load/tests/test_reporting.rs +++ b/crates/compiler/load/tests/test_reporting.rs @@ -11685,31 +11685,6 @@ All branches in an `if` must have the same type! " ); - test_report!( - deprecated_backpassing, - indoc!( - r#" - foo = \bar -> - baz <- Result.try bar - - Ok (baz * 3) - - foo (Ok 123) - "# - ), - @r###" - ── BACKPASSING DEPRECATED in /code/proj/Main.roc ─────────────────────────────── - - Backpassing (<-) like this will soon be deprecated: - - 5│ baz <- Result.try bar - ^^^^^^^^^^^^^^^^^^^^^ - - You should use a ! for awaiting tasks or a ? for trying results, and - functions everywhere else. - "### - ); - test_report!( unknown_shorthand_no_deps, indoc!( diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index c8a878798ec..d31baaaf352 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -535,8 +535,6 @@ pub enum Expr<'a> { /// Multiple defs in a row Defs(&'a Defs<'a>, &'a Loc>), - Backpassing(&'a [Loc>], &'a Loc>, &'a Loc>), - Dbg, DbgStmt { first: &'a Loc>, @@ -722,7 +720,6 @@ pub fn is_expr_suffixed(expr: &Expr) -> bool { Expr::Crash => false, Expr::Tag(_) => false, Expr::OpaqueRef(_) => false, - Expr::Backpassing(_, _, _) => false, // TODO: we might want to check this? Expr::Dbg => false, Expr::DbgStmt { first, @@ -987,11 +984,6 @@ impl<'a, 'b> RecursiveValueDefIter<'a, 'b> { push_stack_from_record_fields!(fields); } Closure(_, body) => expr_stack.push(&body.value), - Backpassing(_, a, b) => { - expr_stack.reserve(2); - expr_stack.push(&a.value); - expr_stack.push(&b.value); - } DbgStmt { first, extra_args, @@ -2575,7 +2567,6 @@ impl<'a> Malformed for Expr<'a> { Closure(args, body) => args.iter().any(|arg| arg.is_malformed()) || body.is_malformed(), Defs(defs, body) => defs.is_malformed() || body.is_malformed(), - Backpassing(args, call, body) => args.iter().any(|arg| arg.is_malformed()) || call.is_malformed() || body.is_malformed(), Dbg => false, DbgStmt { first, extra_args, continuation } => first.is_malformed() || extra_args.iter().any(|a| a.is_malformed()) || continuation.is_malformed(), LowLevelDbg(_, condition, continuation) => condition.is_malformed() || continuation.is_malformed(), diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index c4f1ebe90b4..f73ae02d044 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -51,11 +51,7 @@ pub fn test_parse_expr<'a>( state: State<'a>, ) -> Result>, EExpr<'a>> { let parser = skip_second( - space0_before_optional_after( - loc_expr_block(true, false), - EExpr::IndentStart, - EExpr::IndentEnd, - ), + space0_before_optional_after(loc_expr_block(false), EExpr::IndentStart, EExpr::IndentEnd), expr_end(), ); @@ -65,33 +61,16 @@ pub fn test_parse_expr<'a>( } } +/// Check for the `->` token, and raise an error if found +/// This is usually true, but false in if-guards +/// +/// > Just foo if foo == 2 -> ... #[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct ExprParseOptions { - /// Check for and accept multi-backpassing syntax - /// This is usually true, but false within list/record literals - /// because the comma separating backpassing arguments conflicts - /// with the comma separating literal elements - pub accept_multi_backpassing: bool, - - /// Check for the `->` token, and raise an error if found - /// This is usually true, but false in if-guards - /// - /// > Just foo if foo == 2 -> ... - pub check_for_arrow: bool, -} - -impl ExprParseOptions { - pub fn disallow_multi_backpassing(&self) -> Self { - Self { - accept_multi_backpassing: false, - check_for_arrow: self.check_for_arrow, - } - } -} +pub struct CheckForArrow(pub bool); pub fn expr_help<'a>() -> impl Parser<'a, Expr<'a>, EExpr<'a>> { move |arena, state: State<'a>, min_indent: u32| { - loc_expr(true, false) + loc_expr(false) .parse(arena, state, min_indent) .map(|(a, b, c)| (a, b.value, c)) } @@ -101,7 +80,7 @@ fn loc_expr_in_parens_help<'a>() -> impl Parser<'a, Loc>, EInParens<'a> then( loc(collection_trailing_sep_e( byte(b'(', EInParens::Open), - specialize_err_ref(EInParens::Expr, loc_expr_block(false, true)), + specialize_err_ref(EInParens::Expr, loc_expr_block(true)), byte(b',', EInParens::End), byte(b')', EInParens::End), Expr::SpaceBefore, @@ -190,32 +169,37 @@ fn record_field_access_chain<'a>() -> impl Parser<'a, Vec<'a, Suffix<'a>>, EExpr /// In some contexts we want to parse the `_` as an expression, so it can then be turned into a /// pattern later fn loc_term_or_underscore_or_conditional<'a>( - options: ExprParseOptions, + check_for_arrow: CheckForArrow, allow_conditional: bool, ) -> impl Parser<'a, Loc>, EExpr<'a>> { move |arena: &'a Bump, state: State<'a>, min_indent: u32| { if allow_conditional { - match loc_conditional(options).parse(arena, state.clone(), min_indent) { + match loc_conditional(check_for_arrow).parse(arena, state.clone(), min_indent) { Ok((_, expr, state)) => return Ok((MadeProgress, expr, state)), Err((MadeProgress, e)) => return Err((MadeProgress, e)), Err((NoProgress, _)) => {} } } - loc_term_or_underscore(options).parse(arena, state, min_indent) + loc_term_or_underscore(check_for_arrow).parse(arena, state, min_indent) } } -fn loc_conditional<'a>(options: ExprParseOptions) -> impl Parser<'a, Loc>, EExpr<'a>> { +fn loc_conditional<'a>( + check_for_arrow: CheckForArrow, +) -> impl Parser<'a, Loc>, EExpr<'a>> { one_of!( - loc(specialize_err(EExpr::If, if_expr_help(options))), - loc(specialize_err(EExpr::When, when::when_expr_help(options))), + loc(specialize_err(EExpr::If, if_expr_help(check_for_arrow))), + loc(specialize_err( + EExpr::When, + when::when_expr_help(check_for_arrow) + )), ) } /// In some contexts we want to parse the `_` as an expression, so it can then be turned into a /// pattern later fn loc_term_or_underscore<'a>( - options: ExprParseOptions, + check_for_arrow: CheckForArrow, ) -> impl Parser<'a, Loc>, EExpr<'a>> { one_of!( loc_expr_in_parens_etc_help(), @@ -224,7 +208,10 @@ fn loc_term_or_underscore<'a>( EExpr::Number, positive_number_literal_help() )), - loc(specialize_err(EExpr::Closure, closure_help(options))), + loc(specialize_err( + EExpr::Closure, + closure_help(check_for_arrow) + )), loc(crash_kw()), loc(specialize_err(EExpr::Dbg, dbg_kw())), loc(try_kw()), @@ -236,7 +223,7 @@ fn loc_term_or_underscore<'a>( .trace("term_or_underscore") } -fn loc_term<'a>(options: ExprParseOptions) -> impl Parser<'a, Loc>, EExpr<'a>> { +fn loc_term<'a>(check_for_arrow: CheckForArrow) -> impl Parser<'a, Loc>, EExpr<'a>> { one_of!( loc_expr_in_parens_etc_help(), loc(specialize_err(EExpr::Str, string_like_literal_help())), @@ -244,7 +231,10 @@ fn loc_term<'a>(options: ExprParseOptions) -> impl Parser<'a, Loc>, EEx EExpr::Number, positive_number_literal_help() )), - loc(specialize_err(EExpr::Closure, closure_help(options))), + loc(specialize_err( + EExpr::Closure, + closure_help(check_for_arrow) + )), loc(crash_kw()), loc(specialize_err(EExpr::Dbg, dbg_kw())), loc(try_kw()), @@ -304,7 +294,7 @@ fn crash_kw<'a>() -> impl Parser<'a, Expr<'a>, EExpr<'a>> { } fn loc_possibly_negative_or_negated_term<'a>( - options: ExprParseOptions, + check_for_arrow: CheckForArrow, allow_negate: bool, allow_conditional: bool, ) -> impl Parser<'a, Loc>, EExpr<'a>> { @@ -317,11 +307,7 @@ fn loc_possibly_negative_or_negated_term<'a>( let (_, (loc_op, loc_expr), state) = and( loc(unary_negate()), - loc_possibly_negative_or_negated_term( - options.disallow_multi_backpassing(), - true, - false, - ), + loc_possibly_negative_or_negated_term(check_for_arrow, true, false), ) .parse(arena, state, min_indent)?; @@ -338,11 +324,7 @@ fn loc_possibly_negative_or_negated_term<'a>( and( loc(unary_not()).trace("not"), space0_before_e( - loc_possibly_negative_or_negated_term( - options.disallow_multi_backpassing(), - true, - false - ), + loc_possibly_negative_or_negated_term(check_for_arrow, true, false), EExpr::IndentStart ) .trace("not_expr") @@ -352,7 +334,7 @@ fn loc_possibly_negative_or_negated_term<'a>( } )) .trace("not_expr"), - loc_term_or_underscore_or_conditional(options, allow_conditional) + loc_term_or_underscore_or_conditional(check_for_arrow, allow_conditional) ] .trace("loc_possibly_negative_or_negated_term") } @@ -403,14 +385,20 @@ fn unary_not<'a>() -> impl Parser<'a, (), EExpr<'a>> { /// Entry point for parsing an expression. fn expr_start<'a>( - options: ExprParseOptions, + check_for_arrow: CheckForArrow, allow_any_indent: bool, ) -> impl Parser<'a, Loc>, EExpr<'a>> { one_of![ - loc(specialize_err(EExpr::If, if_expr_help(options))), - loc(specialize_err(EExpr::When, when::when_expr_help(options))), - loc(specialize_err(EExpr::Closure, closure_help(options))), - loc(expr_operator_chain(options, allow_any_indent)), + loc(specialize_err(EExpr::If, if_expr_help(check_for_arrow))), + loc(specialize_err( + EExpr::When, + when::when_expr_help(check_for_arrow) + )), + loc(specialize_err( + EExpr::Closure, + closure_help(check_for_arrow) + )), + loc(expr_operator_chain(check_for_arrow, allow_any_indent)), fail_expr_start_e() ] .trace("expr_start") @@ -418,11 +406,11 @@ fn expr_start<'a>( /// Parse a chain of expressions separated by operators. Also handles function application. fn expr_operator_chain<'a>( - options: ExprParseOptions, + check_for_arrow: CheckForArrow, allow_any_indent: bool, ) -> impl Parser<'a, Expr<'a>, EExpr<'a>> { (move |arena, state: State<'a>, min_indent: u32| { - parse_expr_operator_chain(arena, state, min_indent, options, allow_any_indent) + parse_expr_operator_chain(arena, state, min_indent, check_for_arrow, allow_any_indent) }) .trace("expr_operator_chain") } @@ -431,12 +419,12 @@ fn parse_expr_operator_chain<'a>( arena: &'a Bump, state: State<'a>, min_indent: u32, - options: ExprParseOptions, + check_for_arrow: CheckForArrow, allow_any_indent: bool, ) -> Result<(Progress, Expr<'a>, State<'a>), (Progress, EExpr<'a>)> { let line_indent = state.line_indent(); - let (_, expr, state) = loc_possibly_negative_or_negated_term(options, true, true) + let (_, expr, state) = loc_possibly_negative_or_negated_term(check_for_arrow, true, true) .parse(arena, state, min_indent)?; let mut initial_state = state.clone(); @@ -464,7 +452,7 @@ fn parse_expr_operator_chain<'a>( let allow_negate = state.pos() > end; let parser = skip_first( crate::blankspace::check_indent(EExpr::IndentEnd), - loc_possibly_negative_or_negated_term(options, allow_negate, false), + loc_possibly_negative_or_negated_term(check_for_arrow, allow_negate, false), ) .trace("term_or_underscore"); end = state.pos(); @@ -478,7 +466,7 @@ fn parse_expr_operator_chain<'a>( state, min_indent, call_min_indent, - options, + check_for_arrow, true, expr_state, before_op, @@ -515,7 +503,7 @@ fn parse_expr_after_apply<'a>( state: State<'a>, min_indent: u32, call_min_indent: u32, - options: ExprParseOptions, + check_for_arrow: CheckForArrow, check_for_defs: bool, mut expr_state: ExprState<'a>, before_op: State<'a>, @@ -531,7 +519,7 @@ fn parse_expr_after_apply<'a>( state, min_indent, call_min_indent, - options, + check_for_arrow, check_for_defs, expr_state, loc_op, @@ -565,10 +553,7 @@ pub fn parse_repl_defs_and_optional_expr<'a>( arena, state, |e, _| e.clone(), - ExprParseOptions { - accept_multi_backpassing: true, - check_for_arrow: true, - }, + CheckForArrow(true), 0, spaces_before, EExpr::IndentEnd, @@ -591,37 +576,43 @@ pub fn parse_repl_defs_and_optional_expr<'a>( } fn stmt_start<'a>( - options: ExprParseOptions, + check_for_arrow: CheckForArrow, preceding_comment: Region, ) -> impl Parser<'a, Loc>, EExpr<'a>> { one_of![ map( - loc(specialize_err(EExpr::If, if_expr_help(options))), + loc(specialize_err(EExpr::If, if_expr_help(check_for_arrow))), expr_to_stmt ), map( - loc(specialize_err(EExpr::When, when::when_expr_help(options))), + loc(specialize_err( + EExpr::When, + when::when_expr_help(check_for_arrow) + )), expr_to_stmt ), loc(specialize_err( EExpr::Expect, - expect_help(options, preceding_comment) + expect_help(check_for_arrow, preceding_comment) )), - loc(specialize_err(EExpr::Return, return_help(options))), + loc(specialize_err(EExpr::Return, return_help(check_for_arrow))), loc(specialize_err(EExpr::Import, map(import(), Stmt::ValueDef))), map( - loc(specialize_err(EExpr::Closure, closure_help(options))), + loc(specialize_err( + EExpr::Closure, + closure_help(check_for_arrow) + )), expr_to_stmt ), - loc(stmt_operator_chain(options)), + loc(stmt_operator_chain(check_for_arrow)), fail_expr_start_e() ] .trace("stmt_start") } -fn stmt_operator_chain<'a>(options: ExprParseOptions) -> impl Parser<'a, Stmt<'a>, EExpr<'a>> { +fn stmt_operator_chain<'a>(check_for_arrow: CheckForArrow) -> impl Parser<'a, Stmt<'a>, EExpr<'a>> { (move |arena, state: State<'a>, min_indent: u32| { - parse_stmt_operator_chain(arena, state, min_indent, options) + parse_stmt_operator_chain(arena, state, min_indent, check_for_arrow) }) .trace("stmt_operator_chain") } @@ -630,11 +621,11 @@ fn parse_stmt_operator_chain<'a>( arena: &'a Bump, state: State<'a>, min_indent: u32, - options: ExprParseOptions, + check_for_arrow: CheckForArrow, ) -> Result<(Progress, Stmt<'a>, State<'a>), (Progress, EExpr<'a>)> { let line_indent = state.line_indent(); - let (_, expr, state) = loc_possibly_negative_or_negated_term(options, true, true) + let (_, expr, state) = loc_possibly_negative_or_negated_term(check_for_arrow, true, true) .parse(arena, state, min_indent)?; let mut initial_state = state.clone(); @@ -662,11 +653,7 @@ fn parse_stmt_operator_chain<'a>( let allow_negate = state.pos() > end; let parser = skip_first( crate::blankspace::check_indent(EExpr::IndentEnd), - loc_possibly_negative_or_negated_term( - options.disallow_multi_backpassing(), - allow_negate, - false, - ), + loc_possibly_negative_or_negated_term(check_for_arrow, allow_negate, false), ); end = state.pos(); match parser.parse(arena, state.clone(), call_min_indent) { @@ -695,7 +682,7 @@ fn parse_stmt_operator_chain<'a>( min_indent, call_min_indent, expr_state, - options, + check_for_arrow, initial_state, ); } @@ -787,7 +774,7 @@ impl<'a> ExprState<'a> { } } - fn validate_assignment_or_backpassing( + fn validate_assignment( mut self, arena: &'a Bump, loc_op: Loc, @@ -797,16 +784,8 @@ impl<'a> ExprState<'a> { F: Fn(Region, Position) -> EExpr<'a>, { if !self.operators.is_empty() { - // this `=` or `<-` likely occurred inline; treat it as an invalid operator - let opchar = match loc_op.value { - OperatorOrDef::Assignment => "=", - OperatorOrDef::Backpassing => "<-", - _ => unreachable!(), - }; - - let fail = EExpr::BadOperator(opchar, loc_op.region.start()); - - Err(fail) + // this `=` likely occurred inline; treat it as an invalid operator + Err(EExpr::BadOperator("=", loc_op.region.start())) } else if !self.expr.value.is_tag() && !self.expr.value.is_opaque() && !self.arguments.is_empty() @@ -1468,16 +1447,11 @@ fn finish_parsing_ability_def_help<'a>( /// It consists of a fragment of code that hasn't been fully stitched together yet. /// For example, each of the following lines is a Stmt: /// - `foo bar` (Expr) -/// - `foo, bar <- baz` (Backpassing) /// - `Foo : [A, B, C]` (TypeDef) /// - `foo = \x -> x + 1` (ValueDef) -/// -/// Note in particular that the Backpassing Stmt doesn't make any sense on its own; -/// we need to link it up with the following stmts to make a complete expression. #[derive(Debug, Clone, Copy)] pub enum Stmt<'a> { Expr(Expr<'a>), - Backpassing(&'a [Loc>], &'a Loc>), TypeDef(TypeDef<'a>), ValueDef(ValueDef<'a>), } @@ -1493,7 +1467,7 @@ fn parse_stmt_operator<'a>( state: State<'a>, min_indent: u32, call_min_indent: u32, - options: ExprParseOptions, + check_for_arrow: CheckForArrow, expr_state: ExprState<'a>, loc_op: Loc, initial_state: State<'a>, @@ -1516,7 +1490,7 @@ fn parse_stmt_operator<'a>( min_indent, call_min_indent, expr_state, - options.disallow_multi_backpassing(), + check_for_arrow, initial_state, loc_op.with_value(BinOp::Minus), ) @@ -1527,7 +1501,7 @@ fn parse_stmt_operator<'a>( state, min_indent, call_min_indent, - options, + check_for_arrow, true, spaces_after_operator.value, expr_state, @@ -1540,18 +1514,9 @@ fn parse_stmt_operator<'a>( call_min_indent, expr_state, loc_op, - options, + check_for_arrow, spaces_after_operator, ), - OperatorOrDef::Backpassing => parse_stmt_backpassing( - arena, - state, - call_min_indent, - expr_state, - loc_op, - options, - spaces_after_operator.value, - ), OperatorOrDef::AliasOrOpaque(kind) => parse_stmt_alias_or_opaque( arena, state, @@ -1571,7 +1536,7 @@ fn parse_expr_operator<'a>( state: State<'a>, min_indent: u32, call_min_indent: u32, - options: ExprParseOptions, + check_for_arrow: CheckForArrow, check_for_defs: bool, expr_state: ExprState<'a>, loc_op: Loc, @@ -1593,7 +1558,7 @@ fn parse_expr_operator<'a>( min_indent, call_min_indent, expr_state, - options, + check_for_arrow, initial_state, loc_op, ), @@ -1602,7 +1567,7 @@ fn parse_expr_operator<'a>( state, min_indent, call_min_indent, - options, + check_for_arrow, check_for_defs, spaces_after_operator, expr_state, @@ -1618,13 +1583,13 @@ fn parse_after_binop<'a>( state: State<'a>, min_indent: u32, call_min_indent: u32, - options: ExprParseOptions, + check_for_arrow: CheckForArrow, check_for_defs: bool, spaces_after_operator: &'a [CommentOrNewline], mut expr_state: ExprState<'a>, loc_op: Loc, ) -> ParseResult<'a, Expr<'a>, EExpr<'a>> { - match loc_possibly_negative_or_negated_term(options, true, true).parse( + match loc_possibly_negative_or_negated_term(check_for_arrow, true, true).parse( arena, state.clone(), min_indent, @@ -1671,7 +1636,7 @@ fn parse_after_binop<'a>( state, min_indent, call_min_indent, - options, + check_for_arrow, check_for_defs, expr_state, initial_state, @@ -1685,115 +1650,6 @@ fn parse_after_binop<'a>( } } -/// Parse the rest of a backpassing statement, after the <- operator -fn parse_stmt_backpassing<'a>( - arena: &'a Bump, - state: State<'a>, - call_min_indent: u32, - expr_state: ExprState<'a>, - loc_op: Loc, - options: ExprParseOptions, - spaces_after_operator: &'a [CommentOrNewline], -) -> ParseResult<'a, Stmt<'a>, EExpr<'a>> { - let expr_region = expr_state.expr.region; - - let call = expr_state - .validate_assignment_or_backpassing(arena, loc_op, |_, pos| EExpr::BadOperator("<-", pos)) - .map_err(|fail| (MadeProgress, fail))?; - - let (loc_pattern, loc_body, state) = { - match expr_to_pattern_help(arena, &call.value) { - Ok(good) => { - let (_, mut ann_type, state) = - expr_start(options, false).parse(arena, state, call_min_indent)?; - - // put the spaces from after the operator in front of the call - if !spaces_after_operator.is_empty() { - ann_type = arena - .alloc(ann_type.value) - .with_spaces_before(spaces_after_operator, ann_type.region); - } - - (Loc::at(expr_region, good), ann_type, state) - } - Err(_) => { - // this `=` likely occurred inline; treat it as an invalid operator - let fail = EExpr::BadOperator("=", loc_op.region.start()); - - return Err((MadeProgress, fail)); - } - } - }; - - let ret = Stmt::Backpassing(arena.alloc([loc_pattern]), arena.alloc(loc_body)); - - Ok((MadeProgress, ret, state)) -} - -/// We just saw a `,` that we think is part of a backpassing statement. -/// Parse the rest of the statement. -fn parse_stmt_multi_backpassing<'a>( - mut expr_state: ExprState<'a>, - arena: &'a Bump, - state: State<'a>, - min_indent: u32, - options: ExprParseOptions, -) -> ParseResult<'a, Stmt<'a>, EExpr<'a>> { - // called after parsing the first , in `a, b <- c` (e.g.) - - let (_, mut patterns, state) = specialize_err_ref( - EExpr::Pattern, - crate::parser::sep_by0( - byte(b',', EPattern::Start), - space0_around_ee( - crate::pattern::loc_pattern_help(), - EPattern::Start, - EPattern::IndentEnd, - ), - ), - ) - .parse(arena, state, min_indent) - .map_err(|(progress, err)| { - // We were expecting the end of an expression, and parsed a comma - // therefore we are either on the LHS of backpassing or this is was - // in an invalid position. - if let EExpr::Pattern(EPattern::IndentEnd(_), pos) = err { - (progress, EExpr::UnexpectedComma(pos.sub(1))) - } else { - (progress, err) - } - })?; - - expr_state.consume_spaces(arena); - let call = to_call(arena, expr_state.arguments, expr_state.expr); - - let pattern = expr_to_pattern_help(arena, &call.value).map_err(|()| { - ( - MadeProgress, - EExpr::Pattern(arena.alloc(EPattern::NotAPattern(state.pos())), state.pos()), - ) - })?; - - let loc_pattern = Loc::at(call.region, pattern); - - patterns.insert(0, loc_pattern); - - let line_indent = state.line_indent(); - - match two_bytes(b'<', b'-', EExpr::BackpassArrow).parse(arena, state.clone(), min_indent) { - Err((_, fail)) => Err((MadeProgress, fail)), - Ok((_, _, state)) => { - let parse_body = space0_before_e(expr_start(options, false), EExpr::IndentEnd); - - let (_, loc_body, state) = parse_body.parse(arena, state, line_indent + 1)?; - - let ret = Stmt::Backpassing(patterns.into_bump_slice(), arena.alloc(loc_body)); - - Ok((MadeProgress, ret, state)) - } - } -} - /// We just saw the '=' operator of an assignment stmt. Continue parsing from there. fn parse_stmt_assignment<'a>( arena: &'a Bump, @@ -1801,18 +1657,18 @@ fn parse_stmt_assignment<'a>( call_min_indent: u32, expr_state: ExprState<'a>, loc_op: Loc, - options: ExprParseOptions, + check_for_arrow: CheckForArrow, spaces_after_operator: Loc<&'a [CommentOrNewline]>, ) -> ParseResult<'a, Stmt<'a>, EExpr<'a>> { let call = expr_state - .validate_assignment_or_backpassing(arena, loc_op, EExpr::ElmStyleFunction) + .validate_assignment(arena, loc_op, EExpr::ElmStyleFunction) .map_err(|fail| (MadeProgress, fail))?; let (value_def, state) = { match expr_to_pattern_help(arena, &call.value) { Ok(good) => { let (_, body, state) = parse_block_inner( - options, + check_for_arrow, arena, state, call_min_indent, @@ -1848,11 +1704,11 @@ fn parse_negated_term<'a>( min_indent: u32, call_min_indent: u32, mut expr_state: ExprState<'a>, - options: ExprParseOptions, + check_for_arrow: CheckForArrow, initial_state: State<'a>, loc_op: Loc, ) -> ParseResult<'a, Expr<'a>, EExpr<'a>> { - let (_, negated_expr, state) = loc_term(options).parse(arena, state, min_indent)?; + let (_, negated_expr, state) = loc_term(check_for_arrow).parse(arena, state, min_indent)?; let new_end = state.pos(); let arg = numeric_negate_expression( @@ -1880,7 +1736,7 @@ fn parse_negated_term<'a>( state, min_indent, call_min_indent, - options, + check_for_arrow, true, expr_state, initial_state, @@ -1895,14 +1751,14 @@ fn parse_expr_end<'a>( state: State<'a>, min_indent: u32, call_min_indent: u32, - options: ExprParseOptions, + check_for_arrow: CheckForArrow, check_for_defs: bool, mut expr_state: ExprState<'a>, initial_state: State<'a>, ) -> ParseResult<'a, Expr<'a>, EExpr<'a>> { let parser = skip_first( crate::blankspace::check_indent(EExpr::IndentEnd), - loc_term_or_underscore(options), + loc_term_or_underscore(check_for_arrow), ); match parser.parse(arena, state.clone(), call_min_indent) { @@ -1914,7 +1770,7 @@ fn parse_expr_end<'a>( call_min_indent, expr_state, arg, - options, + check_for_arrow, check_for_defs, ), Err((NoProgress, _)) => { @@ -1930,7 +1786,7 @@ fn parse_expr_end<'a>( state, min_indent, call_min_indent, - options, + check_for_arrow, check_for_defs, expr_state, loc_op, @@ -1960,7 +1816,7 @@ fn parse_stmt_after_apply<'a>( min_indent: u32, call_min_indent: u32, mut expr_state: ExprState<'a>, - options: ExprParseOptions, + check_for_arrow: CheckForArrow, initial_state: State<'a>, ) -> ParseResult<'a, Stmt<'a>, EExpr<'a>> { let before_op = state.clone(); @@ -1974,20 +1830,14 @@ fn parse_stmt_after_apply<'a>( state, min_indent, call_min_indent, - options, + check_for_arrow, expr_state, loc_op, initial_state, ) } Err((NoProgress, _)) => { - let mut state = state; - // try multi-backpassing - if options.accept_multi_backpassing && state.bytes().starts_with(b",") { - state = state.advance(1); - - parse_stmt_multi_backpassing(expr_state, arena, state, min_indent, options) - } else if options.check_for_arrow && state.bytes().starts_with(b"->") { + if check_for_arrow.0 && state.bytes().starts_with(b"->") { Err((MadeProgress, EExpr::BadOperator("->", state.pos()))) } else { let expr = parse_expr_final(expr_state, arena); @@ -1999,6 +1849,43 @@ fn parse_stmt_after_apply<'a>( } } +// #[allow(clippy::too_many_arguments)] +// fn parse_expr_after_apply<'a>( +// arena: &'a Bump, +// state: State<'a>, +// min_indent: u32, +// call_min_indent: u32, +// check_for_arrow: CheckForArrow, +// check_for_defs: bool, +// mut expr_state: ExprState<'a>, +// before_op: State<'a>, +// initial_state: State<'a>, +// ) -> Result<(Progress, Expr<'a>, State<'a>), (Progress, EExpr<'a>)> { +// match loc(bin_op(check_for_defs)).parse(arena, state.clone(), call_min_indent) { +// Err((MadeProgress, f)) => Err((MadeProgress, f)), +// Ok((_, loc_op, state)) => { +// expr_state.consume_spaces(arena); +// let initial_state = before_op; +// parse_expr_operator( +// arena, +// state, +// min_indent, +// call_min_indent, +// options, +// check_for_defs, +// expr_state, +// loc_op, +// initial_state, +// ) +// } +// Err((NoProgress, _)) => { +// let expr = parse_expr_final(expr_state, arena); +// // roll back space parsing +// Ok((MadeProgress, expr, initial_state)) +// } +// } +// } + #[allow(clippy::too_many_arguments)] fn parse_apply_arg<'a>( arena: &'a Bump, @@ -2007,7 +1894,7 @@ fn parse_apply_arg<'a>( call_min_indent: u32, mut expr_state: ExprState<'a>, mut arg: Loc>, - options: ExprParseOptions, + check_for_arrow: CheckForArrow, check_for_defs: bool, ) -> ParseResult<'a, Expr<'a>, EExpr<'a>> { let new_end = state.pos(); @@ -2041,7 +1928,7 @@ fn parse_apply_arg<'a>( state, min_indent, call_min_indent, - options, + check_for_arrow, check_for_defs, expr_state, initial_state, @@ -2094,22 +1981,16 @@ fn parse_ability_def<'a>( Ok((type_def, state)) } -pub fn loc_expr_block<'a>( - accept_multi_backpassing: bool, - allow_any_indent: bool, -) -> impl Parser<'a, Loc>, EExpr<'a>> { +pub fn loc_expr_block<'a>(allow_any_indent: bool) -> impl Parser<'a, Loc>, EExpr<'a>> { space0_after_e( move |arena: &'a Bump, state: State<'a>, min_indent: u32| { - let options = ExprParseOptions { - accept_multi_backpassing, - check_for_arrow: true, - }; + let check_for_arrow = CheckForArrow(true); let (_, loc_first_space, state) = loc_space0_e(EExpr::IndentStart).parse(arena, state, min_indent)?; parse_block_inner( - options, + check_for_arrow, arena, state, min_indent, @@ -2125,18 +2006,9 @@ pub fn loc_expr_block<'a>( .trace("loc_expr_block") } -pub fn loc_expr<'a>( - accept_multi_backpassing: bool, - allow_any_indent: bool, -) -> impl Parser<'a, Loc>, EExpr<'a>> { +pub fn loc_expr<'a>(allow_any_indent: bool) -> impl Parser<'a, Loc>, EExpr<'a>> { space0_before_e( - expr_start( - ExprParseOptions { - accept_multi_backpassing, - check_for_arrow: true, - }, - allow_any_indent, - ), + expr_start(CheckForArrow(true), allow_any_indent), EExpr::IndentEnd, ) } @@ -2239,7 +2111,6 @@ fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result( arena, state, |e, _| e.clone(), - ExprParseOptions { - accept_multi_backpassing: true, - check_for_arrow: true, - }, + CheckForArrow(true), 0, loc_first_space, EExpr::IndentEnd, @@ -2372,7 +2240,7 @@ pub fn parse_top_level_defs<'a>( // PARSER HELPERS -fn closure_help<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a>, EClosure<'a>> { +fn closure_help<'a>(check_for_arrow: CheckForArrow) -> impl Parser<'a, Expr<'a>, EClosure<'a>> { // closure_help_help(options) map_with_arena( // After the first token, all other tokens must be indented past the start of the line @@ -2397,7 +2265,7 @@ fn closure_help<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a>, EClo // Parse the -> which separates params from body two_bytes(b'-', b'>', EClosure::Arrow), // Parse the body - block(options, true, EClosure::IndentBody, EClosure::Body), + block(check_for_arrow, true, EClosure::IndentBody, EClosure::Body), ), ), ), @@ -2416,13 +2284,15 @@ mod when { use crate::{ast::WhenBranch, blankspace::space0_around_e_no_after_indent_check}; /// Parser for when expressions. - pub fn when_expr_help<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a>, EWhen<'a>> { + pub fn when_expr_help<'a>( + check_for_arrow: CheckForArrow, + ) -> impl Parser<'a, Expr<'a>, EWhen<'a>> { map_with_arena( and( indented_seq_skip_first( parser::keyword(keyword::WHEN, EWhen::When), space0_around_e_no_after_indent_check( - specialize_err_ref(EWhen::Condition, expr_start(options, true)), + specialize_err_ref(EWhen::Condition, expr_start(check_for_arrow, true)), EWhen::IndentCondition, ) ), @@ -2432,7 +2302,7 @@ mod when { // We require that branches are indented relative to the line containing the `is`. indented_seq_skip_first( parser::keyword(keyword::IS, EWhen::Is), - branches(options) + branches() ) ), move |arena: &'a Bump, (loc_condition, branches): (Loc>, Vec<'a, &'a WhenBranch<'a>>)| { @@ -2441,9 +2311,7 @@ mod when { ).trace("when") } - fn branches<'a>( - options: ExprParseOptions, - ) -> impl Parser<'a, Vec<'a, &'a WhenBranch<'a>>, EWhen<'a>> { + fn branches<'a>() -> impl Parser<'a, Vec<'a, &'a WhenBranch<'a>>, EWhen<'a>> { move |arena, state: State<'a>, min_indent: u32| { let mut branches: Vec<'a, &'a WhenBranch<'a>> = Vec::with_capacity_in(2, arena); @@ -2454,13 +2322,13 @@ mod when { _, ((_, _), _), State<'a>, - ) = branch_alternatives(options, None).parse(arena, state, min_indent)?; + ) = branch_alternatives(None).parse(arena, state, min_indent)?; let original_indent = pattern_indent_level; // Parse the first "->" and the expression after it. - let (_, loc_first_expr, mut state) = branch_result(options, original_indent + 1) - .parse(arena, state, original_indent + 1)?; + let (_, loc_first_expr, mut state) = + branch_result(original_indent + 1).parse(arena, state, original_indent + 1)?; // Record this as the first branch, then optionally parse additional branches. branches.push(arena.alloc(WhenBranch { @@ -2472,7 +2340,7 @@ mod when { let branch_parser = map( and( then( - branch_alternatives(options, Some(pattern_indent_level)), + branch_alternatives(Some(pattern_indent_level)), move |_arena, state, _, ((indent_column, loc_patterns), loc_guard)| { if pattern_indent_level == indent_column { Ok((MadeProgress, (loc_patterns, loc_guard), state)) @@ -2482,7 +2350,7 @@ mod when { } }, ), - branch_result(options, original_indent + 1), + branch_result(original_indent + 1), ), |((patterns, guard), expr)| { let patterns: Vec<'a, _> = patterns; @@ -2516,13 +2384,10 @@ mod when { /// Parsing alternative patterns in `when` branches. fn branch_alternatives<'a>( - options: ExprParseOptions, pattern_indent_level: Option, ) -> impl Parser<'a, ((u32, Vec<'a, Loc>>), Option>>), EWhen<'a>> { - let options = ExprParseOptions { - check_for_arrow: false, - ..options - }; + let check_for_arrow = CheckForArrow(false); + and( branch_alternatives_help(pattern_indent_level), one_of![ @@ -2533,7 +2398,7 @@ mod when { space0_around_ee( specialize_err_ref( EWhen::IfGuard, - increment_min_indent(expr_start(options, true)) + increment_min_indent(expr_start(check_for_arrow, true)) ), EWhen::IndentIfGuard, EWhen::IndentArrow, @@ -2634,16 +2499,16 @@ mod when { } /// Parsing the righthandside of a branch in a when conditional. - fn branch_result<'a>( - mut options: ExprParseOptions, - indent: u32, - ) -> impl Parser<'a, Loc>, EWhen<'a>> { - // it's important we preserve the value of `accept_multi_backpassing` in case it's false - options.check_for_arrow = true; + fn branch_result<'a>(indent: u32) -> impl Parser<'a, Loc>, EWhen<'a>> { move |arena, state, _min_indent| { skip_first( two_bytes(b'-', b'>', EWhen::Arrow), - block(options, true, EWhen::IndentBranch, EWhen::Branch), + block( + CheckForArrow(true), + true, + EWhen::IndentBranch, + EWhen::Branch, + ), ) .parse(arena, state, indent) } @@ -2651,15 +2516,13 @@ mod when { } fn if_branch<'a>() -> impl Parser<'a, ((Loc>, u32), Loc>), EIf<'a>> { - let options = ExprParseOptions { - accept_multi_backpassing: true, - check_for_arrow: true, - }; + let check_for_arrow = CheckForArrow(true); + skip_second( and( and( space0_around_ee( - specialize_err_ref(EIf::Condition, loc_expr(true, false)), + specialize_err_ref(EIf::Condition, loc_expr(false)), EIf::IndentCondition, EIf::IndentThenToken, ) @@ -2671,7 +2534,12 @@ fn if_branch<'a>() -> impl Parser<'a, ((Loc>, u32), Loc>), EIf ), map_with_arena( space0_after_e( - block(options, false, EIf::IndentThenBranch, EIf::ThenBranch), + block( + check_for_arrow, + false, + EIf::IndentThenBranch, + EIf::ThenBranch, + ), EIf::IndentElseToken, ), |arena: &'a Bump, block: Loc>| match block.value { @@ -2688,7 +2556,7 @@ fn if_branch<'a>() -> impl Parser<'a, ((Loc>, u32), Loc>), EIf } fn expect_help<'a>( - options: ExprParseOptions, + check_for_arrow: CheckForArrow, preceding_comment: Region, ) -> impl Parser<'a, Stmt<'a>, EExpect<'a>> { move |arena: &'a Bump, state: State<'a>, min_indent| { @@ -2697,7 +2565,7 @@ fn expect_help<'a>( let (_, _kw, state) = parse_expect.parse(arena, state, min_indent)?; let (_, condition, state) = parse_block( - options, + check_for_arrow, arena, state, true, @@ -2715,13 +2583,13 @@ fn expect_help<'a>( } } -fn return_help<'a>(options: ExprParseOptions) -> impl Parser<'a, Stmt<'a>, EReturn<'a>> { +fn return_help<'a>(check_for_arrow: CheckForArrow) -> impl Parser<'a, Stmt<'a>, EReturn<'a>> { (move |arena: &'a Bump, state: State<'a>, min_indent| { let (_, return_kw, state) = loc(parser::keyword(keyword::RETURN, EReturn::Return)) .parse(arena, state, min_indent)?; let (_, return_value, state) = parse_block( - options, + check_for_arrow, arena, state, true, @@ -2772,7 +2640,7 @@ fn import<'a>() -> impl Parser<'a, ValueDef<'a>, EImport<'a>> { ) } -fn if_expr_help<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a>, EIf<'a>> { +fn if_expr_help<'a>(check_for_arrow: CheckForArrow) -> impl Parser<'a, Expr<'a>, EIf<'a>> { (move |arena: &'a Bump, state, min_indent| { let (_, _, state) = parser::keyword(keyword::IF, EIf::If) .trace("if_kw") @@ -2827,7 +2695,7 @@ fn if_expr_help<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a>, EIf< // use parse_block_inner so we can set min_indent let (_, else_branch, state) = parse_block_inner( - options, + check_for_arrow, arena, state_final_else, min_indent, @@ -2852,7 +2720,7 @@ fn if_expr_help<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a>, EIf< /// Parse a block of statements (parser combinator version of `parse_block`) fn block<'a, E>( - options: ExprParseOptions, + check_for_arrow: CheckForArrow, require_indent: bool, indent_problem: fn(Position) -> E, wrap_error: fn(&'a EExpr<'a>, Position) -> E, @@ -2862,7 +2730,7 @@ where { (move |arena: &'a Bump, state, _min_indent| { parse_block( - options, + check_for_arrow, arena, state, require_indent, @@ -2879,7 +2747,7 @@ where /// 1. If there is a preceding newline, then the block must be indented and is allowed to have definitions. /// 2. If there is no preceding newline, then the block must consist of a single expression (no definitions). fn parse_block<'a, E>( - options: ExprParseOptions, + check_for_arrow: CheckForArrow, arena: &'a Bump, state: State<'a>, require_indent: bool, @@ -2901,7 +2769,7 @@ where let allow_defs = !loc_first_space.value.is_empty(); parse_block_inner( - options, + check_for_arrow, arena, state, min_indent, @@ -2918,7 +2786,7 @@ where /// and decided whether to allow definitions. #[allow(clippy::too_many_arguments)] fn parse_block_inner<'a, E>( - options: ExprParseOptions, + check_for_arrow: CheckForArrow, arena: &'a Bump, state: State<'a>, min_indent: u32, @@ -2936,7 +2804,7 @@ where arena, state, wrap_error, - options, + check_for_arrow, min_indent, Loc::at(first_space.region, &[]), indent_problem, @@ -2965,7 +2833,7 @@ where Ok((MadeProgress, loc_expr, state)) } else { let (p2, loc_expr, state) = - specialize_err_ref(wrap_error, expr_start(options, allow_any_indent)) + specialize_err_ref(wrap_error, expr_start(check_for_arrow, allow_any_indent)) .parse(arena, state, min_indent)?; let loc_expr = if first_space.value.is_empty() { @@ -2985,15 +2853,14 @@ where /// - assignments /// - type annotations /// - expressions -/// - [multi]backpassing /// /// This function doesn't care about whether the order of those statements makes any sense. -/// e.g. it will happily parse two expressions in a row, or backpassing with nothing following it. +/// e.g. it will happily parse two expressions in a row. fn parse_stmt_seq<'a, E: SpaceProblem + 'a>( arena: &'a Bump, mut state: State<'a>, wrap_error: fn(&'a EExpr<'a>, Position) -> E, - options: ExprParseOptions, + check_for_arrow: CheckForArrow, min_indent: u32, mut last_space: Loc<&'a [CommentOrNewline<'a>]>, indent_problem: fn(Position) -> E, @@ -3006,29 +2873,30 @@ fn parse_stmt_seq<'a, E: SpaceProblem + 'a>( break; } - let loc_stmt = match specialize_err_ref(wrap_error, stmt_start(options, last_space.region)) - .parse(arena, state.clone(), min_indent) - { - Ok((_p, s, new_state)) => { - state_before_space = new_state.clone(); - state = new_state; - s - } - Err((NoProgress, _)) => { - if stmts.is_empty() { - return Err(( - NoProgress, - wrap_error(arena.alloc(EExpr::Start(state.pos())), state.pos()), - )); + let loc_stmt = + match specialize_err_ref(wrap_error, stmt_start(check_for_arrow, last_space.region)) + .parse(arena, state.clone(), min_indent) + { + Ok((_p, s, new_state)) => { + state_before_space = new_state.clone(); + state = new_state; + s } + Err((NoProgress, _)) => { + if stmts.is_empty() { + return Err(( + NoProgress, + wrap_error(arena.alloc(EExpr::Start(state.pos())), state.pos()), + )); + } - state = state_before_space; - break; - } - Err((MadeProgress, e)) => { - return Err((MadeProgress, e)); - } - }; + state = state_before_space; + break; + } + Err((MadeProgress, e)) => { + return Err((MadeProgress, e)); + } + }; stmts.push(SpacesBefore { before: last_space.value, @@ -3129,7 +2997,7 @@ fn stmts_to_expr<'a>( loc_stmt.region.start(), )); } - Stmt::Backpassing(..) | Stmt::TypeDef(_) | Stmt::ValueDef(_) => { + Stmt::TypeDef(_) | Stmt::ValueDef(_) => { return Err(EExpr::IndentEnd(loc_stmt.region.end())) } }; @@ -3224,29 +3092,6 @@ fn stmts_to_defs<'a>( last_expr = Some(sp_stmt.item.with_value(e)); } } - Stmt::Backpassing(pats, call) => { - if i + 1 >= stmts.len() { - return Err(EExpr::BackpassContinue(sp_stmt.item.region.end())); - } - - let rest = stmts_to_expr(&stmts[i + 1..], arena)?; - - let e = Expr::Backpassing(arena.alloc(pats), arena.alloc(call), arena.alloc(rest)); - - let e = if sp_stmt.before.is_empty() { - e - } else { - arena.alloc(e).before(sp_stmt.before) - }; - - let region = Region::new(sp_stmt.item.region.start(), rest.region.end()); - - last_expr = Some(Loc::at(region, e)); - - // don't re-process the rest of the statements; they got consumed by the backpassing - break; - } - Stmt::TypeDef(td) => { if let ( TypeDef::Alias { @@ -3591,7 +3436,7 @@ fn list_literal_help<'a>() -> impl Parser<'a, Expr<'a>, EList<'a>> { map_with_arena( collection_trailing_sep_e( byte(b'[', EList::Open), - specialize_err_ref(EList::Expr, loc_expr(false, true)), + specialize_err_ref(EList::Expr, loc_expr(true)), byte(b',', EList::End), byte(b']', EList::End), Expr::SpaceBefore, @@ -3684,7 +3529,7 @@ pub fn record_field<'a>() -> impl Parser<'a, RecordField<'a>, ERecord<'a>> { and(byte(b':', ERecord::Colon), record_field_expr()), and( byte(b'?', ERecord::QuestionMark), - spaces_before(specialize_err_ref(ERecord::Expr, loc_expr(false, true))), + spaces_before(specialize_err_ref(ERecord::Expr, loc_expr(true))), ), )), ), @@ -3701,7 +3546,7 @@ pub fn record_field<'a>() -> impl Parser<'a, RecordField<'a>, ERecord<'a>> { spaces(), skip_first( byte(b':', ERecord::Colon), - spaces_before(specialize_err_ref(ERecord::Expr, loc_expr(false, false))), + spaces_before(specialize_err_ref(ERecord::Expr, loc_expr(false))), ), ), ), @@ -3742,10 +3587,7 @@ pub fn record_field<'a>() -> impl Parser<'a, RecordField<'a>, ERecord<'a>> { fn record_field_expr<'a>() -> impl Parser<'a, Loc>, ERecord<'a>> { map_with_arena( - and( - spaces(), - specialize_err_ref(ERecord::Expr, loc_expr(false, false)), - ), + and(spaces(), specialize_err_ref(ERecord::Expr, loc_expr(false))), |arena: &'a bumpalo::Bump, (spaces, loc_expr)| { if spaces.is_empty() { loc_expr @@ -3980,7 +3822,6 @@ enum OperatorOrDef { BinOp(BinOp), Assignment, AliasOrOpaque(AliasOrOpaque), - Backpassing, } fn bin_op<'a>(check_for_defs: bool) -> impl Parser<'a, BinOp, EExpr<'a>> { @@ -4001,7 +3842,6 @@ fn bin_op<'a>(check_for_defs: bool) -> impl Parser<'a, BinOp, EExpr<'a>> { OperatorOrDef::AliasOrOpaque(AliasOrOpaque::Opaque) => { Err((err_progress, EExpr::BadOperator(":=", start))) } - OperatorOrDef::Backpassing => Err((err_progress, EExpr::BadOperator("<-", start))), } } } @@ -4083,7 +3923,6 @@ where // makes no progress, so it does not interfere with `_ if isGood -> ...` Err((NoProgress, to_error("->", state.pos()))) } - "<-" => good!(OperatorOrDef::Backpassing, 2), "!" => Err((NoProgress, to_error("!", state.pos()))), "&" => { // makes no progress, so it does not interfere with record updaters / `&foo` diff --git a/crates/compiler/parse/src/highlight.rs b/crates/compiler/parse/src/highlight.rs index e54809b2e82..2e5549d468c 100644 --- a/crates/compiler/parse/src/highlight.rs +++ b/crates/compiler/parse/src/highlight.rs @@ -59,7 +59,7 @@ pub enum Token { Paren, Arrow, Pipe, - Backpass, + BackArrow, Decimal, Multiply, Underscore, @@ -257,7 +257,7 @@ fn highlight_inner<'a>( Token::LessThanEquals } else if state.bytes().first() == Some(&b'-') { state.advance_mut(1); - Token::Backpass + Token::BackArrow } else { Token::LessThan }; @@ -556,7 +556,7 @@ mod tests { ), Loc::at( Region::between(Position::new(6), Position::new(8)), - Token::Backpass, + Token::BackArrow, ), Loc::at( Region::between(Position::new(9), Position::new(11)), diff --git a/crates/compiler/parse/src/normalize.rs b/crates/compiler/parse/src/normalize.rs index 78b7e88961c..9fe034ade88 100644 --- a/crates/compiler/parse/src/normalize.rs +++ b/crates/compiler/parse/src/normalize.rs @@ -716,11 +716,6 @@ impl<'a> Normalize<'a> for Expr<'a> { ), Expr::Crash => Expr::Crash, Expr::Defs(a, b) => fold_defs(arena, a.defs(), b.value.normalize(arena)), - Expr::Backpassing(a, b, c) => Expr::Backpassing( - arena.alloc(a.normalize(arena)), - arena.alloc(b.normalize(arena)), - arena.alloc(c.normalize(arena)), - ), Expr::Dbg => Expr::Dbg, Expr::DbgStmt { first, @@ -1083,9 +1078,6 @@ impl<'a> Normalize<'a> for EExpr<'a> { } EExpr::MalformedPattern(_pos) => EExpr::MalformedPattern(Position::zero()), EExpr::QualifiedTag(_pos) => EExpr::QualifiedTag(Position::zero()), - EExpr::BackpassComma(_pos) => EExpr::BackpassComma(Position::zero()), - EExpr::BackpassArrow(_pos) => EExpr::BackpassArrow(Position::zero()), - EExpr::BackpassContinue(_pos) => EExpr::BackpassContinue(Position::zero()), EExpr::DbgContinue(_pos) => EExpr::DbgContinue(Position::zero()), EExpr::When(inner_err, _pos) => { EExpr::When(inner_err.normalize(arena), Position::zero()) diff --git a/crates/compiler/parse/src/parser.rs b/crates/compiler/parse/src/parser.rs index 4f5f2b8d765..4723dfbb264 100644 --- a/crates/compiler/parse/src/parser.rs +++ b/crates/compiler/parse/src/parser.rs @@ -519,9 +519,6 @@ pub enum EExpr<'a> { ElmStyleFunction(Region, Position), MalformedPattern(Position), QualifiedTag(Position), - BackpassComma(Position), - BackpassArrow(Position), - BackpassContinue(Position), DbgContinue(Position), When(EWhen<'a>, Position), @@ -603,9 +600,6 @@ impl<'a> EExpr<'a> { | EExpr::ElmStyleFunction(_, p) | EExpr::MalformedPattern(p) | EExpr::QualifiedTag(p) - | EExpr::BackpassComma(p) - | EExpr::BackpassArrow(p) - | EExpr::BackpassContinue(p) | EExpr::DbgContinue(p) | EExpr::Underscore(p) | EExpr::Crash(p) diff --git a/crates/compiler/parse/src/pattern.rs b/crates/compiler/parse/src/pattern.rs index 37bb1f4ed48..65538e80035 100644 --- a/crates/compiler/parse/src/pattern.rs +++ b/crates/compiler/parse/src/pattern.rs @@ -548,8 +548,7 @@ fn record_pattern_field<'a>() -> impl Parser<'a, Loc>, PRecord<'a>> )) } Some(Second(_)) => { - let val_parser = - specialize_err_ref(PRecord::Expr, crate::expr::loc_expr(false, false)); + let val_parser = specialize_err_ref(PRecord::Expr, crate::expr::loc_expr(false)); let (_, loc_val, state) = spaces_before(val_parser).parse(arena, state, min_indent)?; diff --git a/crates/compiler/problem/src/can.rs b/crates/compiler/problem/src/can.rs index d6d15778b62..861f80bad9b 100644 --- a/crates/compiler/problem/src/can.rs +++ b/crates/compiler/problem/src/can.rs @@ -53,7 +53,6 @@ pub enum Problem { new_symbol: Symbol, existing_symbol_region: Region, }, - DeprecatedBackpassing(Region), /// First symbol is the name of the closure with that argument /// Bool is whether the closure is anonymous /// Second symbol is the name of the argument that is unused @@ -278,7 +277,6 @@ impl Problem { Problem::ExplicitBuiltinImport(_, _) => Warning, Problem::ExplicitBuiltinTypeImport(_, _) => Warning, Problem::ImportShadowsSymbol { .. } => RuntimeError, - Problem::DeprecatedBackpassing(_) => Warning, Problem::ExposedButNotDefined(_) => RuntimeError, Problem::UnusedArgument(_, _, _, _) => Warning, Problem::UnusedBranchDef(_, _) => Warning, @@ -372,7 +370,6 @@ impl Problem { | Problem::ExplicitBuiltinImport(_, region) | Problem::ExplicitBuiltinTypeImport(_, region) | Problem::ImportShadowsSymbol { region, .. } - | Problem::DeprecatedBackpassing(region) | Problem::UnusedArgument(_, _, _, region) | Problem::UnusedBranchDef(_, region) | Problem::PrecedenceProblem(PrecedenceProblem::BothNonAssociative(region, _, _)) diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/backpassing_after_annotation.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/fail/backpassing_after_annotation.expr.result-ast deleted file mode 100644 index 88ad924cba0..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/fail/backpassing_after_annotation.expr.result-ast +++ /dev/null @@ -1 +0,0 @@ -Expr(BackpassContinue(@8), @0) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/backpassing_after_annotation.expr.roc b/crates/compiler/test_syntax/tests/snapshots/fail/backpassing_after_annotation.expr.roc deleted file mode 100644 index 38c82263c85..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/fail/backpassing_after_annotation.expr.roc +++ /dev/null @@ -1,2 +0,0 @@ -u:i -e<-x diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/expr_to_pattern_fail.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/fail/expr_to_pattern_fail.expr.result-ast index 2644392b1de..77f11c1de87 100644 --- a/crates/compiler/test_syntax/tests/snapshots/fail/expr_to_pattern_fail.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/fail/expr_to_pattern_fail.expr.result-ast @@ -1 +1 @@ -Expr(Pattern(NotAPattern(@3), @3), @0) \ No newline at end of file +Expr(BadExprEnd(@2), @0) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/expression_indentation_end.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/fail/expression_indentation_end.expr.result-ast deleted file mode 100644 index d2f1c32c260..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/fail/expression_indentation_end.expr.result-ast +++ /dev/null @@ -1 +0,0 @@ -Expr(IndentEnd(@12), @0) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/expression_indentation_end.expr.roc b/crates/compiler/test_syntax/tests/snapshots/fail/expression_indentation_end.expr.roc deleted file mode 100644 index 34cc01384a0..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/fail/expression_indentation_end.expr.roc +++ /dev/null @@ -1 +0,0 @@ -f <- Foo.foo diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/implements_in_multibackpassing_parens.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/fail/implements_in_multibackpassing_parens.expr.result-ast deleted file mode 100644 index 3aaf7d49523..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/fail/implements_in_multibackpassing_parens.expr.result-ast +++ /dev/null @@ -1 +0,0 @@ -Expr(BackpassArrow(@3), @0) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/implements_in_multibackpassing_parens.expr.roc b/crates/compiler/test_syntax/tests/snapshots/fail/implements_in_multibackpassing_parens.expr.roc deleted file mode 100644 index ee24d84f38f..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/fail/implements_in_multibackpassing_parens.expr.roc +++ /dev/null @@ -1,3 +0,0 @@ -n,U(implements -)<-t -9 diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/not_closure_with_multibackpassing.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/fail/not_closure_with_multibackpassing.expr.result-ast deleted file mode 100644 index 18cb7538420..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/fail/not_closure_with_multibackpassing.expr.result-ast +++ /dev/null @@ -1 +0,0 @@ -Expr(Pattern(NotAPattern(@10), @10), @0) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/not_closure_with_multibackpassing.expr.roc b/crates/compiler/test_syntax/tests/snapshots/fail/not_closure_with_multibackpassing.expr.roc deleted file mode 100644 index f0e9650a379..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/fail/not_closure_with_multibackpassing.expr.roc +++ /dev/null @@ -1,3 +0,0 @@ -!\t-> - m,i<-0 - s diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_bananza.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_bananza.expr.formatted.roc deleted file mode 100644 index b50df3b3d59..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_bananza.expr.formatted.roc +++ /dev/null @@ -1,4 +0,0 @@ -ex <- f # -s # q - <- f # -s \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_bananza.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_bananza.expr.result-ast deleted file mode 100644 index 3d32e82c5b9..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_bananza.expr.result-ast +++ /dev/null @@ -1,52 +0,0 @@ -@1-18 SpaceBefore( - Backpassing( - [ - @1-3 Identifier { - ident: "ex", - }, - ], - @5-6 Var { - module_name: "", - ident: "f", - }, - @8-18 SpaceBefore( - Backpassing( - [ - @8-9 SpaceAfter( - Identifier { - ident: "s", - }, - [ - LineComment( - "q", - ), - ], - ), - ], - @14-15 Var { - module_name: "", - ident: "f", - }, - @17-18 SpaceBefore( - Var { - module_name: "", - ident: "s", - }, - [ - LineComment( - "", - ), - ], - ), - ), - [ - LineComment( - "", - ), - ], - ), - ), - [ - Newline, - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_bananza.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_bananza.expr.roc deleted file mode 100644 index d36d0292632..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_bananza.expr.roc +++ /dev/null @@ -1,5 +0,0 @@ - -ex<-f# -s#q -<-f# -s \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_comment_pattern_fun.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_comment_pattern_fun.expr.formatted.roc deleted file mode 100644 index 67114b8e890..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_comment_pattern_fun.expr.formatted.roc +++ /dev/null @@ -1,5 +0,0 @@ -1, - (C # - 0) # - <- F -t \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_comment_pattern_fun.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_comment_pattern_fun.expr.result-ast deleted file mode 100644 index ae3e35b5966..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_comment_pattern_fun.expr.result-ast +++ /dev/null @@ -1,53 +0,0 @@ -@0-16 SpaceAfter( - Backpassing( - [ - @0-1 NumLiteral( - "1", - ), - @2-7 SpaceAfter( - Apply( - @2-3 Tag( - "C", - ), - [ - @6-7 SpaceBefore( - SpaceAfter( - NumLiteral( - "0", - ), - [ - Newline, - ], - ), - [ - LineComment( - "", - ), - ], - ), - ], - ), - [ - LineComment( - "", - ), - ], - ), - ], - @13-14 Tag( - "F", - ), - @15-16 SpaceBefore( - Var { - module_name: "", - ident: "t", - }, - [ - Newline, - ], - ), - ), - [ - Newline, - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_comment_pattern_fun.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_comment_pattern_fun.expr.roc deleted file mode 100644 index 3de8d2bf6c5..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_comment_pattern_fun.expr.roc +++ /dev/null @@ -1,5 +0,0 @@ -1,C(# -0 -)# -<-F -t diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_in_parens_in_tuple.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_in_parens_in_tuple.expr.formatted.roc deleted file mode 100644 index afa410a4801..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_in_parens_in_tuple.expr.formatted.roc +++ /dev/null @@ -1,5 +0,0 @@ -( - b, - M <- f - 3, -) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_in_parens_in_tuple.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_in_parens_in_tuple.expr.result-ast deleted file mode 100644 index 4f44cf58210..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_in_parens_in_tuple.expr.result-ast +++ /dev/null @@ -1,39 +0,0 @@ -@0-14 Tuple( - [ - @1-2 SpaceAfter( - Var { - module_name: "", - ident: "b", - }, - [ - Newline, - ], - ), - @4-13 Backpassing( - [ - @4-5 Tag( - "M", - ), - ], - @7-8 Var { - module_name: "", - ident: "f", - }, - @9-13 SpaceBefore( - ParensAround( - SpaceAfter( - Num( - "3", - ), - [ - Newline, - ], - ), - ), - [ - Newline, - ], - ), - ), - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_in_parens_in_tuple.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_in_parens_in_tuple.expr.roc deleted file mode 100644 index 0acd86d4d9f..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_in_parens_in_tuple.expr.roc +++ /dev/null @@ -1,4 +0,0 @@ -(b -,M<-f -(3 -)) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_parens_comment.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_parens_comment.expr.formatted.roc deleted file mode 100644 index 72b7c6d4de0..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_parens_comment.expr.formatted.roc +++ /dev/null @@ -1,4 +0,0 @@ -8 <- p -# - -T \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_parens_comment.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_parens_comment.expr.result-ast deleted file mode 100644 index 101381f67f5..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_parens_comment.expr.result-ast +++ /dev/null @@ -1,34 +0,0 @@ -@0-11 SpaceAfter( - Backpassing( - [ - @0-1 NumLiteral( - "8", - ), - ], - @3-9 ParensAround( - SpaceAfter( - Var { - module_name: "", - ident: "p", - }, - [ - Newline, - LineComment( - "", - ), - ], - ), - ), - @10-11 SpaceBefore( - Tag( - "T", - ), - [ - Newline, - ], - ), - ), - [ - Newline, - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_parens_comment.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_parens_comment.expr.roc deleted file mode 100644 index 5165cf4f486..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_parens_comment.expr.roc +++ /dev/null @@ -1,4 +0,0 @@ -8<-(p -# -) -T diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_pattern_weirdness.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_pattern_weirdness.expr.formatted.roc deleted file mode 100644 index 7cfbedabe03..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_pattern_weirdness.expr.formatted.roc +++ /dev/null @@ -1,8 +0,0 @@ -({ p ? ( - p -) - f, p ? ( - p -) - p? } A) <- I -S \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_pattern_weirdness.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_pattern_weirdness.expr.result-ast deleted file mode 100644 index 9e1be4988ed..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_pattern_weirdness.expr.result-ast +++ /dev/null @@ -1,80 +0,0 @@ -@0-24 SpaceAfter( - Backpassing( - [ - @0-18 Apply( - @0-18 RecordDestructure( - [ - @1-8 OptionalField( - "p", - @3-8 Apply( - @4-5 ParensAround( - SpaceAfter( - Var { - module_name: "", - ident: "p", - }, - [ - Newline, - ], - ), - ), - [ - @7-8 Var { - module_name: "", - ident: "f", - }, - ], - Space, - ), - ), - @9-17 OptionalField( - "p", - @11-17 Apply( - @12-13 ParensAround( - SpaceAfter( - Var { - module_name: "", - ident: "p", - }, - [ - Newline, - ], - ), - ), - [ - @15-16 TrySuffix { - target: Result, - expr: Var { - module_name: "", - ident: "p", - }, - }, - ], - Space, - ), - ), - ], - ), - [ - @18-19 Tag( - "A", - ), - ], - ), - ], - @21-22 Tag( - "I", - ), - @23-24 SpaceBefore( - Tag( - "S", - ), - [ - Newline, - ], - ), - ), - [ - Newline, - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_pattern_weirdness.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_pattern_weirdness.expr.roc deleted file mode 100644 index 2fe9dc4f662..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_pattern_weirdness.expr.roc +++ /dev/null @@ -1,4 +0,0 @@ -{p?(p -)f,p?(p -)p?}A<-I -S diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_record_str_crazyness.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_record_str_crazyness.expr.formatted.roc deleted file mode 100644 index 4140d06ba1a..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_record_str_crazyness.expr.formatted.roc +++ /dev/null @@ -1,10 +0,0 @@ -({ p ? { -} - n, -p ? p? - { - } - c } - "") - <- I -S \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_record_str_crazyness.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_record_str_crazyness.expr.result-ast deleted file mode 100644 index 08f0e1b9d83..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_record_str_crazyness.expr.result-ast +++ /dev/null @@ -1,80 +0,0 @@ -@0-24 SpaceAfter( - Backpassing( - [ - @0-17 Apply( - @0-17 RecordDestructure( - [ - @1-7 OptionalField( - "p", - @3-7 Apply( - @3-6 Record( - Collection { - items: [], - final_comments: [ - Newline, - ], - }, - ), - [ - @6-7 Var { - module_name: "", - ident: "n", - }, - ], - Space, - ), - ), - @8-16 OptionalField( - "p", - @10-16 Apply( - @10-11 TrySuffix { - target: Result, - expr: Var { - module_name: "", - ident: "p", - }, - }, - [ - @12-15 Record( - Collection { - items: [], - final_comments: [ - Newline, - ], - }, - ), - @15-16 Var { - module_name: "", - ident: "c", - }, - ], - Space, - ), - ), - ], - ), - [ - @17-19 StrLiteral( - PlainLine( - "", - ), - ), - ], - ), - ], - @21-22 Tag( - "I", - ), - @23-24 SpaceBefore( - Tag( - "S", - ), - [ - Newline, - ], - ), - ), - [ - Newline, - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_record_str_crazyness.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_record_str_crazyness.expr.roc deleted file mode 100644 index 9b630aeb9cd..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/backpassing_record_str_crazyness.expr.roc +++ /dev/null @@ -1,4 +0,0 @@ -{p?{ -}n,p?p?{ -}c}""<-I -S diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/comment_in_backpassing_args.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/comment_in_backpassing_args.expr.formatted.roc deleted file mode 100644 index 265ee78e3f8..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/comment_in_backpassing_args.expr.formatted.roc +++ /dev/null @@ -1,5 +0,0 @@ -a, - (M # - c) - <- t -a \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/comment_in_backpassing_args.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/comment_in_backpassing_args.expr.result-ast deleted file mode 100644 index 926596639ec..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/comment_in_backpassing_args.expr.result-ast +++ /dev/null @@ -1,37 +0,0 @@ -@0-11 Backpassing( - [ - @0-1 Identifier { - ident: "a", - }, - @2-6 Apply( - @2-3 Tag( - "M", - ), - [ - @5-6 SpaceBefore( - Identifier { - ident: "c", - }, - [ - LineComment( - "", - ), - ], - ), - ], - ), - ], - @8-9 Var { - module_name: "", - ident: "t", - }, - @10-11 SpaceBefore( - Var { - module_name: "", - ident: "a", - }, - [ - Newline, - ], - ), -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/comment_in_backpassing_args.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/comment_in_backpassing_args.expr.roc deleted file mode 100644 index 8bedbac5bbe..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/comment_in_backpassing_args.expr.roc +++ /dev/null @@ -1,3 +0,0 @@ -a,M# -c<-t -a \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/crazy_backpassing_parens.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/crazy_backpassing_parens.expr.formatted.roc deleted file mode 100644 index fc7dfb37263..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/crazy_backpassing_parens.expr.formatted.roc +++ /dev/null @@ -1,4 +0,0 @@ -( - M0 <- f - 1) -1 \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/crazy_backpassing_parens.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/crazy_backpassing_parens.expr.result-ast deleted file mode 100644 index f7dc9b4b120..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/crazy_backpassing_parens.expr.result-ast +++ /dev/null @@ -1,63 +0,0 @@ -@0-15 Defs( - Defs { - tags: [ - EitherIndex(2147483648), - ], - regions: [ - @0-10, - ], - space_before: [ - Slice { start: 0, length: 0 }, - ], - space_after: [ - Slice { start: 0, length: 0 }, - ], - spaces: [], - type_defs: [], - value_defs: [ - Stmt( - @0-10 ParensAround( - SpaceBefore( - Backpassing( - [ - @2-4 Tag( - "M0", - ), - ], - @6-7 Var { - module_name: "", - ident: "f", - }, - @8-9 SpaceBefore( - Num( - "1", - ), - [ - Newline, - ], - ), - ), - [ - Newline, - ], - ), - ), - ), - ], - }, - @11-15 SpaceBefore( - ParensAround( - SpaceBefore( - Num( - "1", - ), - [ - Newline, - ], - ), - ), - [ - Newline, - ], - ), -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/crazy_backpassing_parens.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/crazy_backpassing_parens.expr.roc deleted file mode 100644 index c994b5e17a1..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/crazy_backpassing_parens.expr.roc +++ /dev/null @@ -1,5 +0,0 @@ -( -M0<-f -1) -( -1) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/double_parens_as_in_backpassing_pat.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/double_parens_as_in_backpassing_pat.expr.formatted.roc deleted file mode 100644 index 620e62df101..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/double_parens_as_in_backpassing_pat.expr.formatted.roc +++ /dev/null @@ -1,2 +0,0 @@ -0, (m as l) as l <- w -i \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/double_parens_as_in_backpassing_pat.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/double_parens_as_in_backpassing_pat.expr.result-ast deleted file mode 100644 index ef11485e5ba..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/double_parens_as_in_backpassing_pat.expr.result-ast +++ /dev/null @@ -1,40 +0,0 @@ -@0-21 SpaceAfter( - Backpassing( - [ - @0-1 NumLiteral( - "0", - ), - @4-15 As( - @4-10 As( - @4-5 Identifier { - ident: "m", - }, - PatternAs { - spaces_before: [], - identifier: @9-10 "l", - }, - ), - PatternAs { - spaces_before: [], - identifier: @14-15 "l", - }, - ), - ], - @18-19 Var { - module_name: "", - ident: "w", - }, - @20-21 SpaceBefore( - Var { - module_name: "", - ident: "i", - }, - [ - Newline, - ], - ), - ), - [ - Newline, - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/double_parens_as_in_backpassing_pat.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/double_parens_as_in_backpassing_pat.expr.roc deleted file mode 100644 index 613e7a94009..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/double_parens_as_in_backpassing_pat.expr.roc +++ /dev/null @@ -1,2 +0,0 @@ -0,((m as l)as l)<-w -i diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/empty_record_assign_backpassing.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/empty_record_assign_backpassing.expr.formatted.roc deleted file mode 100644 index 78917aed471..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/empty_record_assign_backpassing.expr.formatted.roc +++ /dev/null @@ -1,4 +0,0 @@ -{} = - i <- t - C -C \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/empty_record_assign_backpassing.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/empty_record_assign_backpassing.expr.result-ast deleted file mode 100644 index 74ab690666b..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/empty_record_assign_backpassing.expr.result-ast +++ /dev/null @@ -1,62 +0,0 @@ -@0-14 SpaceAfter( - Defs( - Defs { - tags: [ - EitherIndex(2147483648), - ], - regions: [ - @0-12, - ], - space_before: [ - Slice { start: 0, length: 0 }, - ], - space_after: [ - Slice { start: 0, length: 0 }, - ], - spaces: [], - type_defs: [], - value_defs: [ - Body( - @0-2 RecordDestructure( - [], - ), - @5-12 SpaceBefore( - Backpassing( - [ - @5-6 Identifier { - ident: "i", - }, - ], - @8-9 Var { - module_name: "", - ident: "t", - }, - @11-12 SpaceBefore( - Tag( - "C", - ), - [ - Newline, - ], - ), - ), - [ - Newline, - ], - ), - ), - ], - }, - @13-14 SpaceBefore( - Tag( - "C", - ), - [ - Newline, - ], - ), - ), - [ - Newline, - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/empty_record_assign_backpassing.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/empty_record_assign_backpassing.expr.roc deleted file mode 100644 index 9562668d259..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/empty_record_assign_backpassing.expr.roc +++ /dev/null @@ -1,4 +0,0 @@ -{}= - i<-t - C -C diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/indented_after_multi_backpassing.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/indented_after_multi_backpassing.expr.formatted.roc deleted file mode 100644 index 9ccdd8a175b..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/indented_after_multi_backpassing.expr.formatted.roc +++ /dev/null @@ -1,6 +0,0 @@ -fillBucketsFromData = \buckets0, data, shifts -> - buckets1, (key, _), dataIndex <- List.walkWithIndex data buckets0 - (bucketIndex, distAndFingerprint) = nextWhileLess buckets1 key shifts - placeAndShiftUp buckets1 { distAndFingerprint, dataIndex: Num.toU32 dataIndex } bucketIndex - -foo \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/indented_after_multi_backpassing.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/indented_after_multi_backpassing.expr.result-ast deleted file mode 100644 index 23a57bcd351..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/indented_after_multi_backpassing.expr.result-ast +++ /dev/null @@ -1,196 +0,0 @@ -@0-293 SpaceAfter( - Defs( - Defs { - tags: [ - EitherIndex(2147483648), - ], - regions: [ - @0-288, - ], - space_before: [ - Slice { start: 0, length: 0 }, - ], - space_after: [ - Slice { start: 0, length: 0 }, - ], - spaces: [], - type_defs: [], - value_defs: [ - Body( - @0-19 Identifier { - ident: "fillBucketsFromData", - }, - @22-288 Closure( - [ - @23-31 Identifier { - ident: "buckets0", - }, - @33-37 Identifier { - ident: "data", - }, - @39-45 Identifier { - ident: "shifts", - }, - ], - @53-288 SpaceBefore( - Backpassing( - [ - @53-61 Identifier { - ident: "buckets1", - }, - @63-71 Tuple( - [ - @64-67 Identifier { - ident: "key", - }, - @69-70 Underscore( - "", - ), - ], - ), - @73-82 Identifier { - ident: "dataIndex", - }, - ], - @86-118 Apply( - @86-104 Var { - module_name: "List", - ident: "walkWithIndex", - }, - [ - @105-109 Var { - module_name: "", - ident: "data", - }, - @110-118 Var { - module_name: "", - ident: "buckets0", - }, - ], - Space, - ), - @123-288 Defs( - Defs { - tags: [ - EitherIndex(2147483648), - ], - regions: [ - @123-192, - ], - space_before: [ - Slice { start: 0, length: 1 }, - ], - space_after: [ - Slice { start: 1, length: 0 }, - ], - spaces: [ - Newline, - ], - type_defs: [], - value_defs: [ - Body( - @123-156 Tuple( - [ - @124-135 Identifier { - ident: "bucketIndex", - }, - @137-155 Identifier { - ident: "distAndFingerprint", - }, - ], - ), - @159-192 Apply( - @159-172 Var { - module_name: "", - ident: "nextWhileLess", - }, - [ - @173-181 Var { - module_name: "", - ident: "buckets1", - }, - @182-185 Var { - module_name: "", - ident: "key", - }, - @186-192 Var { - module_name: "", - ident: "shifts", - }, - ], - Space, - ), - ), - ], - }, - @197-288 SpaceBefore( - Apply( - @197-212 Var { - module_name: "", - ident: "placeAndShiftUp", - }, - [ - @213-221 Var { - module_name: "", - ident: "buckets1", - }, - @222-276 Record( - [ - @224-242 LabelOnly( - @224-242 "distAndFingerprint", - ), - @244-274 RequiredValue( - @244-253 "dataIndex", - [], - @255-274 Apply( - @255-264 Var { - module_name: "Num", - ident: "toU32", - }, - [ - @265-274 Var { - module_name: "", - ident: "dataIndex", - }, - ], - Space, - ), - ), - ], - ), - @277-288 Var { - module_name: "", - ident: "bucketIndex", - }, - ], - Space, - ), - [ - Newline, - ], - ), - ), - ), - [ - Newline, - ], - ), - ), - ), - ], - }, - @290-293 SpaceBefore( - Var { - module_name: "", - ident: "foo", - }, - [ - Newline, - Newline, - ], - ), - ), - [ - Newline, - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/indented_after_multi_backpassing.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/indented_after_multi_backpassing.expr.roc deleted file mode 100644 index c1bac9b6141..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/indented_after_multi_backpassing.expr.roc +++ /dev/null @@ -1,6 +0,0 @@ -fillBucketsFromData = \buckets0, data, shifts -> - buckets1, (key, _), dataIndex <- List.walkWithIndex data buckets0 - (bucketIndex, distAndFingerprint) = nextWhileLess buckets1 key shifts - placeAndShiftUp buckets1 { distAndFingerprint, dataIndex: Num.toU32 dataIndex } bucketIndex - -foo diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing.expr.formatted.roc deleted file mode 100644 index d4c0fbdec34..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing.expr.formatted.roc +++ /dev/null @@ -1,3 +0,0 @@ -x, y <- List.map2 [] [] - -x + y \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing.expr.result-ast deleted file mode 100644 index 2612f9ffb09..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing.expr.result-ast +++ /dev/null @@ -1,51 +0,0 @@ -@0-30 SpaceAfter( - Backpassing( - [ - @0-1 Identifier { - ident: "x", - }, - @3-4 Identifier { - ident: "y", - }, - ], - @8-23 Apply( - @8-17 Var { - module_name: "List", - ident: "map2", - }, - [ - @18-20 List( - [], - ), - @21-23 List( - [], - ), - ], - Space, - ), - @25-30 SpaceBefore( - BinOps( - [ - ( - @25-26 Var { - module_name: "", - ident: "x", - }, - @27-28 Plus, - ), - ], - @29-30 Var { - module_name: "", - ident: "y", - }, - ), - [ - Newline, - Newline, - ], - ), - ), - [ - Newline, - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing.expr.roc deleted file mode 100644 index 06a44541836..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing.expr.roc +++ /dev/null @@ -1,3 +0,0 @@ -x, y <- List.map2 [] [] - -x + y diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_in_def.moduledefs.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_in_def.moduledefs.formatted.roc deleted file mode 100644 index 825368a8d9f..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_in_def.moduledefs.formatted.roc +++ /dev/null @@ -1,3 +0,0 @@ -main = - arg1, arg2 <- f {} - "Roc <3 Zig!\n" diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_in_def.moduledefs.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_in_def.moduledefs.result-ast deleted file mode 100644 index 570b112bafa..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_in_def.moduledefs.result-ast +++ /dev/null @@ -1,69 +0,0 @@ -Defs { - tags: [ - EitherIndex(2147483648), - ], - regions: [ - @0-50, - ], - space_before: [ - Slice { start: 0, length: 0 }, - ], - space_after: [ - Slice { start: 0, length: 1 }, - ], - spaces: [ - Newline, - ], - type_defs: [], - value_defs: [ - Body( - @0-4 Identifier { - ident: "main", - }, - @12-50 SpaceBefore( - Backpassing( - [ - @12-16 Identifier { - ident: "arg1", - }, - @18-22 Identifier { - ident: "arg2", - }, - ], - @26-30 Apply( - @26-27 Var { - module_name: "", - ident: "f", - }, - [ - @28-30 Record( - [], - ), - ], - Space, - ), - @35-50 SpaceBefore( - Str( - Line( - [ - Plaintext( - "Roc <3 Zig!", - ), - EscapedChar( - Newline, - ), - ], - ), - ), - [ - Newline, - ], - ), - ), - [ - Newline, - ], - ), - ), - ], -} diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_in_def.moduledefs.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_in_def.moduledefs.roc deleted file mode 100644 index 336af68069d..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_in_def.moduledefs.roc +++ /dev/null @@ -1,3 +0,0 @@ -main = - arg1, arg2 <- f {} - "Roc <3 Zig!\n" diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_with_apply.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_with_apply.expr.formatted.roc deleted file mode 100644 index 43444cf3824..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_with_apply.expr.formatted.roc +++ /dev/null @@ -1,2 +0,0 @@ -(F 1), r <- a -W \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_with_apply.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_with_apply.expr.result-ast deleted file mode 100644 index a531fddf629..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_with_apply.expr.result-ast +++ /dev/null @@ -1,29 +0,0 @@ -@0-13 Backpassing( - [ - @0-3 Apply( - @0-1 Tag( - "F", - ), - [ - @2-3 NumLiteral( - "1", - ), - ], - ), - @5-6 Identifier { - ident: "r", - }, - ], - @10-11 Var { - module_name: "", - ident: "a", - }, - @12-13 SpaceBefore( - Tag( - "W", - ), - [ - Newline, - ], - ), -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_with_apply.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_with_apply.expr.roc deleted file mode 100644 index c8fea3186b7..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multi_backpassing_with_apply.expr.roc +++ /dev/null @@ -1,2 +0,0 @@ -F 1, r <- a -W \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_backpassing.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_backpassing.expr.formatted.roc deleted file mode 100644 index 6dadcdd8f82..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_backpassing.expr.formatted.roc +++ /dev/null @@ -1,4 +0,0 @@ -d -t # - <- b --f \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_backpassing.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_backpassing.expr.result-ast deleted file mode 100644 index 76fdc1201ae..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_backpassing.expr.result-ast +++ /dev/null @@ -1,61 +0,0 @@ -@0-12 Defs( - Defs { - tags: [ - EitherIndex(2147483648), - ], - regions: [ - @0-1, - ], - space_before: [ - Slice { start: 0, length: 0 }, - ], - space_after: [ - Slice { start: 0, length: 0 }, - ], - spaces: [], - type_defs: [], - value_defs: [ - Stmt( - @0-1 Var { - module_name: "", - ident: "d", - }, - ), - ], - }, - @2-12 SpaceBefore( - Backpassing( - [ - @2-3 SpaceAfter( - Identifier { - ident: "t", - }, - [ - LineComment( - "", - ), - ], - ), - ], - @8-9 Var { - module_name: "", - ident: "b", - }, - @10-12 SpaceBefore( - UnaryOp( - @11-12 Var { - module_name: "", - ident: "f", - }, - @10-11 Negate, - ), - [ - Newline, - ], - ), - ), - [ - Newline, - ], - ), -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_backpassing.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_backpassing.expr.roc deleted file mode 100644 index f0354d4a608..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_backpassing.expr.roc +++ /dev/null @@ -1,4 +0,0 @@ -d -t # -<-b --f \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_in_backpassing_pats.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_in_backpassing_pats.expr.formatted.roc deleted file mode 100644 index 4102231af04..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_in_backpassing_pats.expr.formatted.roc +++ /dev/null @@ -1,7 +0,0 @@ -1, - (A - """ - """ - J) - <- o -O \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_in_backpassing_pats.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_in_backpassing_pats.expr.result-ast deleted file mode 100644 index 22a1aff9522..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_in_backpassing_pats.expr.result-ast +++ /dev/null @@ -1,46 +0,0 @@ -@0-18 SpaceAfter( - Backpassing( - [ - @0-1 NumLiteral( - "1", - ), - @2-13 Apply( - @2-3 Tag( - "A", - ), - [ - @6-12 SpaceBefore( - StrLiteral( - Block( - [], - ), - ), - [ - Newline, - Newline, - Newline, - ], - ), - @12-13 Tag( - "J", - ), - ], - ), - ], - @15-16 Var { - module_name: "", - ident: "o", - }, - @17-18 SpaceBefore( - Tag( - "O", - ), - [ - Newline, - ], - ), - ), - [ - Newline, - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_in_backpassing_pats.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_in_backpassing_pats.expr.roc deleted file mode 100644 index 7effb652aee..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_in_backpassing_pats.expr.roc +++ /dev/null @@ -1,5 +0,0 @@ -1,A - - -""""""J<-o -O diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/one_backpassing.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/one_backpassing.expr.formatted.roc deleted file mode 100644 index 4ec34629b49..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/one_backpassing.expr.formatted.roc +++ /dev/null @@ -1,4 +0,0 @@ -# leading comment -x <- \y -> y - -x \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/one_backpassing.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/one_backpassing.expr.result-ast deleted file mode 100644 index 8b22fc2cb99..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/one_backpassing.expr.result-ast +++ /dev/null @@ -1,42 +0,0 @@ -@18-35 SpaceBefore( - SpaceAfter( - Backpassing( - [ - @18-19 Identifier { - ident: "x", - }, - ], - @23-32 ParensAround( - Closure( - [ - @25-26 Identifier { - ident: "y", - }, - ], - @30-31 Var { - module_name: "", - ident: "y", - }, - ), - ), - @34-35 SpaceBefore( - Var { - module_name: "", - ident: "x", - }, - [ - Newline, - Newline, - ], - ), - ), - [ - Newline, - ], - ), - [ - LineComment( - " leading comment", - ), - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/one_backpassing.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/one_backpassing.expr.roc deleted file mode 100644 index a7cfb742042..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/one_backpassing.expr.roc +++ /dev/null @@ -1,4 +0,0 @@ -# leading comment -x <- (\y -> y) - -x diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/repr_7343.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/repr_7343.expr.formatted.roc deleted file mode 100644 index 1067caef3cb..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/repr_7343.expr.formatted.roc +++ /dev/null @@ -1,6 +0,0 @@ -( - i <- ( - dbg 0 - _) - 9 -) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/repr_7343.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/repr_7343.expr.result-ast deleted file mode 100644 index b7e55e8df5b..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/repr_7343.expr.result-ast +++ /dev/null @@ -1,40 +0,0 @@ -@0-18 SpaceAfter( - ParensAround( - ParensAround( - Backpassing( - [ - @2-3 Identifier { - ident: "i", - }, - ], - @5-14 ParensAround( - DbgStmt { - first: @10-11 Num( - "0", - ), - extra_args: [], - continuation: @12-13 SpaceBefore( - Underscore( - "", - ), - [ - Newline, - ], - ), - }, - ), - @15-16 SpaceBefore( - Num( - "9", - ), - [ - Newline, - ], - ), - ), - ), - ), - [ - Newline, - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/repr_7343.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/repr_7343.expr.roc deleted file mode 100644 index 7def50ae12c..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/repr_7343.expr.roc +++ /dev/null @@ -1,3 +0,0 @@ -((i<-(dbg 0 -_) -9)) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/return_backpassing.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/return_backpassing.expr.formatted.roc deleted file mode 100644 index 23fd5fc4c85..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/return_backpassing.expr.formatted.roc +++ /dev/null @@ -1,3 +0,0 @@ -return - u <- _ - m \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/return_backpassing.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/return_backpassing.expr.result-ast deleted file mode 100644 index be0a498e038..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/return_backpassing.expr.result-ast +++ /dev/null @@ -1,32 +0,0 @@ -@0-15 SpaceAfter( - Return( - @0-15 SpaceBefore( - Backpassing( - [ - @8-9 Identifier { - ident: "u", - }, - ], - @11-12 Underscore( - "", - ), - @14-15 SpaceBefore( - Var { - module_name: "", - ident: "m", - }, - [ - Newline, - ], - ), - ), - [ - Newline, - ], - ), - None, - ), - [ - Newline, - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/return_backpassing.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/return_backpassing.expr.roc deleted file mode 100644 index 4a788a3b675..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/return_backpassing.expr.roc +++ /dev/null @@ -1,3 +0,0 @@ -return - u<-_ - m diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/two_backpassing.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/two_backpassing.expr.formatted.roc deleted file mode 100644 index 89c3bc7993e..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/two_backpassing.expr.formatted.roc +++ /dev/null @@ -1,5 +0,0 @@ -# leading comment -x <- \y -> y -z <- {} - -x \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/two_backpassing.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/two_backpassing.expr.result-ast deleted file mode 100644 index b7860cbd941..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/two_backpassing.expr.result-ast +++ /dev/null @@ -1,57 +0,0 @@ -@18-43 SpaceBefore( - SpaceAfter( - Backpassing( - [ - @18-19 Identifier { - ident: "x", - }, - ], - @23-32 ParensAround( - Closure( - [ - @25-26 Identifier { - ident: "y", - }, - ], - @30-31 Var { - module_name: "", - ident: "y", - }, - ), - ), - @33-43 SpaceBefore( - Backpassing( - [ - @33-34 Identifier { - ident: "z", - }, - ], - @38-40 Record( - [], - ), - @42-43 SpaceBefore( - Var { - module_name: "", - ident: "x", - }, - [ - Newline, - Newline, - ], - ), - ), - [ - Newline, - ], - ), - ), - [ - Newline, - ], - ), - [ - LineComment( - " leading comment", - ), - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/two_backpassing.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/two_backpassing.expr.roc deleted file mode 100644 index 051228bc5e4..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/two_backpassing.expr.roc +++ /dev/null @@ -1,5 +0,0 @@ -# leading comment -x <- (\y -> y) -z <- {} - -x diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/underscore_backpassing.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/underscore_backpassing.expr.formatted.roc deleted file mode 100644 index 85986c6c486..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/underscore_backpassing.expr.formatted.roc +++ /dev/null @@ -1,4 +0,0 @@ -# leading comment -_ <- \y -> y - -4 \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/underscore_backpassing.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/underscore_backpassing.expr.result-ast deleted file mode 100644 index d3db2a6b98f..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/underscore_backpassing.expr.result-ast +++ /dev/null @@ -1,41 +0,0 @@ -@18-35 SpaceBefore( - SpaceAfter( - Backpassing( - [ - @18-19 Underscore( - "", - ), - ], - @23-32 ParensAround( - Closure( - [ - @25-26 Identifier { - ident: "y", - }, - ], - @30-31 Var { - module_name: "", - ident: "y", - }, - ), - ), - @34-35 SpaceBefore( - Num( - "4", - ), - [ - Newline, - Newline, - ], - ), - ), - [ - Newline, - ], - ), - [ - LineComment( - " leading comment", - ), - ], -) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/underscore_backpassing.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/underscore_backpassing.expr.roc deleted file mode 100644 index 3e0d8ca803e..00000000000 --- a/crates/compiler/test_syntax/tests/snapshots/pass/underscore_backpassing.expr.roc +++ /dev/null @@ -1,4 +0,0 @@ -# leading comment -_ <- (\y -> y) - -4 diff --git a/crates/compiler/test_syntax/tests/test_fmt.rs b/crates/compiler/test_syntax/tests/test_fmt.rs index 534912e5837..9bba68ad361 100644 --- a/crates/compiler/test_syntax/tests/test_fmt.rs +++ b/crates/compiler/test_syntax/tests/test_fmt.rs @@ -3002,23 +3002,6 @@ mod test_fmt { " ), ); - - expr_formats_to( - indoc!( - r" - { } <- f a b - - {} - " - ), - indoc!( - r" - {} <- f a b - - {} - " - ), - ); } #[test] @@ -5284,113 +5267,6 @@ mod test_fmt { )); } - #[test] - fn backpassing_simple() { - expr_formats_same(indoc!( - r" - get_char = \ctx -> - x <- Task.await (get_char_scope scope) - 42 - - 42 - " - )); - } - - #[test] - fn backpassing_apply_tag() { - expr_formats_same(indoc!( - r" - get_char = \ctx -> - (T val new_scope) <- Task.await (get_char_scope scope) - 42 - - 42 - " - )); - } - - #[test] - fn backpassing_parens_body() { - expr_formats_same(indoc!( - r" - Task.fromResult - ( - b <- binaryOp ctx - if a == b then - -1 - else - 0 - ) - " - )); - - expr_formats_to( - indoc!( - r" - Task.fromResult - (b <- binaryOp ctx - if a == b then - -1 - else - 0 - ) - " - ), - indoc!( - r" - Task.fromResult - ( - b <- binaryOp ctx - if a == b then - -1 - else - 0 - ) - " - ), - ); - - expr_formats_to( - indoc!( - r" - Task.fromResult - (b <- binaryOp ctx - if a == b then - -1 - else - 0) - " - ), - indoc!( - r" - Task.fromResult - ( - b <- binaryOp ctx - if a == b then - -1 - else - 0 - ) - " - ), - ); - } - - #[test] - fn backpassing_body_on_newline() { - expr_formats_same(indoc!( - r" - get_char = \ctx -> - x <- - Task.await (get_char_scope scope) - 42 - - 42 - " - )); - } - #[test] fn multiline_higher_order_function() { expr_formats_same(indoc!( diff --git a/crates/compiler/test_syntax/tests/test_snapshots.rs b/crates/compiler/test_syntax/tests/test_snapshots.rs index eb417886557..6a4da79a86f 100644 --- a/crates/compiler/test_syntax/tests/test_snapshots.rs +++ b/crates/compiler/test_syntax/tests/test_snapshots.rs @@ -187,7 +187,6 @@ mod test_snapshots { fail/ability_first_demand_not_indented_enough.expr, fail/ability_non_signature_expression.expr, fail/alias_or_opaque_fail.expr, - fail/backpassing_after_annotation.expr, fail/bound_variable.expr, fail/comment_with_tab.expr, fail/d_assign_return_bang.expr, @@ -207,13 +206,11 @@ mod test_snapshots { fail/exponential_else_branch_parsing_repro.expr, fail/exposed_type_bang.header, fail/expr_to_pattern_fail.expr, - fail/expression_indentation_end.expr, fail/if_guard_without_condition.expr, fail/if_missing_else.expr, fail/if_outdented_else_branch.expr, fail/if_outdented_then.expr, fail/ifbang_eqeq.expr, - fail/implements_in_multibackpassing_parens.expr, fail/import_with_lowercase_alias.moduledefs, fail/imports_missing_comma.header, fail/inline_hastype.expr, @@ -233,7 +230,6 @@ mod test_snapshots { fail/nested_tuples_annotation_terrible_perf.expr, fail/nested_when_expect_binop_when.expr, fail/newline_before_operator_with_defs.expr, - fail/not_closure_with_multibackpassing.expr, fail/oom_repro.expr, fail/opaque_type_def_with_newline.expr, fail/pattern_binds_keyword.expr, @@ -334,12 +330,6 @@ mod test_snapshots { pass/apply_unary_not.expr, pass/arg_pattern_as.expr, pass/as_in_func_type_args.expr, - pass/backpassing_bananza.expr, - pass/backpassing_comment_pattern_fun.expr, - pass/backpassing_in_parens_in_tuple.expr, - pass/backpassing_parens_comment.expr, - pass/backpassing_pattern_weirdness.expr, - pass/backpassing_record_str_crazyness.expr, pass/bang_newline_double_accessor.expr, pass/bangs_and_tuple_accessors.expr, pass/basic_apply.expr, @@ -378,7 +368,6 @@ mod test_snapshots { pass/comment_before_equals_def.expr, pass/comment_before_op.expr, pass/comment_before_pat_in_parens.expr, - pass/comment_in_backpassing_args.expr, pass/comment_in_closure_pat.expr, pass/comment_in_closure_pat_apply.expr, pass/comment_in_tuple_ext.expr, @@ -391,7 +380,6 @@ mod test_snapshots { pass/crash.expr, pass/crazy_annotation_left.expr, pass/crazy_annotation_left2.expr, - pass/crazy_backpassing_parens.expr, pass/crazy_implements_bangs.expr, pass/crazy_pat_ann.expr, pass/curried_function_type.expr, @@ -412,7 +400,6 @@ mod test_snapshots { pass/docs.expr, pass/double_closure_newlines_binop.expr, pass/double_function_tuple.expr, - pass/double_parens_as_in_backpassing_pat.expr, pass/double_parens_comment_tuple_pat.expr, pass/double_question_binop.expr, pass/double_space_before.expr, @@ -424,7 +411,6 @@ mod test_snapshots { pass/empty_package_header.header, pass/empty_platform_header.header, pass/empty_record.expr, - pass/empty_record_assign_backpassing.expr, pass/empty_record_assign_dbg.expr, pass/empty_record_assign_implements.expr, pass/empty_record_assign_return.expr, @@ -476,7 +462,6 @@ mod test_snapshots { pass/import_with_comments.moduledefs, pass/import_with_exposed.moduledefs, pass/import_with_params.moduledefs, - pass/indented_after_multi_backpassing.expr, pass/ingested_file.moduledefs, pass/inline_import.expr, pass/inline_ingested_file.expr, @@ -516,19 +501,14 @@ mod test_snapshots { pass/module_with_params.header, pass/module_with_params_and_multiline_exposes.header, pass/mul_comment_neg.expr, - pass/multi_backpassing.expr, - pass/multi_backpassing_in_def.moduledefs, - pass/multi_backpassing_with_apply.expr, pass/multi_char_string.expr, pass/multilin_str_body.expr, pass/multiline_apply_equals_multiline_apply.expr, - pass/multiline_backpassing.expr, pass/multiline_binop_when_with_comments.expr, pass/multiline_str_after_newlines_in_pat.expr, pass/multiline_str_and_str_in_alias.expr, pass/multiline_str_apply_in_parens_pat.expr, pass/multiline_str_crazyness.expr, - pass/multiline_str_in_backpassing_pats.expr, pass/multiline_str_in_pat.expr, pass/multiline_str_interpolation_records.expr, pass/multiline_str_opt_field.expr, @@ -582,7 +562,6 @@ mod test_snapshots { pass/number_literal_suffixes.expr, pass/old_app_header.full, pass/old_interface_header.header, - pass/one_backpassing.expr, pass/one_char_string.expr, pass/one_def.expr, pass/one_minus_two.expr, @@ -666,11 +645,9 @@ mod test_snapshots { pass/record_with_if.expr, pass/record_with_lots_of_newlines.expr, pass/repr_7342.expr, - pass/repr_7343.expr, pass/repr_7346.expr, pass/requires_type.header, pass/return_apply_newline.expr, - pass/return_backpassing.expr, pass/return_field_access_in_parens.expr, pass/return_in_apply_func.expr, pass/return_in_if.expr, @@ -729,7 +706,6 @@ mod test_snapshots { pass/tuple_type_ext.expr, pass/tuples_parens_comments.expr, pass/two_arg_closure.expr, - pass/two_backpassing.expr, pass/two_branch_when.expr, pass/two_spaced_def.expr, pass/type_ann_tag_union_parens_applies.expr, @@ -743,7 +719,6 @@ mod test_snapshots { pass/unary_negation_with_parens.expr, pass/unary_not.expr, pass/unary_not_with_parens.expr, - pass/underscore_backpassing.expr, pass/underscore_expr_in_def.expr, pass/underscore_in_assignment_pattern.expr, pass/unicode_overflow_str.expr, diff --git a/crates/highlight/src/lib.rs b/crates/highlight/src/lib.rs index b31694c9fc6..5e582d2eab2 100644 --- a/crates/highlight/src/lib.rs +++ b/crates/highlight/src/lib.rs @@ -51,7 +51,7 @@ pub fn highlight(code: &str) -> Vec { | Token::Backslash | Token::Pizza | Token::Arrow - | Token::Backpass + | Token::BackArrow | Token::ColonEquals | Token::Colon | Token::And diff --git a/crates/language_server/src/analysis/tokens.rs b/crates/language_server/src/analysis/tokens.rs index 1f1fe3fbb32..9e1ef85b2f1 100644 --- a/crates/language_server/src/analysis/tokens.rs +++ b/crates/language_server/src/analysis/tokens.rs @@ -682,10 +682,6 @@ impl IterTokens for Loc> { Expr::Defs(defs, exprs) => (defs.iter_tokens(arena).into_iter()) .chain(exprs.iter_tokens(arena)) .collect_in(arena), - Expr::Backpassing(patterns, e1, e2) => (patterns.iter_tokens(arena).into_iter()) - .chain(e1.iter_tokens(arena)) - .chain(e2.iter_tokens(arena)) - .collect_in(arena), Expr::Dbg => onetoken(Token::Keyword, region, arena), Expr::DbgStmt { first, diff --git a/crates/reporting/src/error/canonicalize.rs b/crates/reporting/src/error/canonicalize.rs index d5fded833d5..d296f48a550 100644 --- a/crates/reporting/src/error/canonicalize.rs +++ b/crates/reporting/src/error/canonicalize.rs @@ -1,5 +1,4 @@ use roc_collections::all::MutSet; -use roc_module::called_via::Suffix; use roc_module::ident::{Ident, Lowercase, ModuleName}; use roc_module::symbol::DERIVABLE_ABILITIES; use roc_problem::can::PrecedenceProblem::BothNonAssociative; @@ -251,26 +250,6 @@ pub fn can_problem<'b>( title = DUPLICATE_NAME.to_string(); } - Problem::DeprecatedBackpassing(region) => { - doc = alloc.stack([ - alloc.concat([ - alloc.reflow("Backpassing ("), - alloc.backpassing_arrow(), - alloc.reflow(") like this will soon be deprecated:"), - ]), - alloc.region(lines.convert_region(region), severity), - alloc.concat([ - alloc.reflow("You should use a "), - alloc.suffix(Suffix::Bang), - alloc.reflow(" for awaiting tasks or a "), - alloc.suffix(Suffix::Question), - alloc.reflow(" for trying results, and functions everywhere else."), - ]), - ]); - - title = "BACKPASSING DEPRECATED".to_string(); - } - Problem::DefsOnlyUsedInRecursion(1, region) => { doc = alloc.stack([ alloc.reflow("This definition is only used in recursion with itself:"), diff --git a/crates/reporting/src/error/parse.rs b/crates/reporting/src/error/parse.rs index fba6434a884..7098bca2125 100644 --- a/crates/reporting/src/error/parse.rs +++ b/crates/reporting/src/error/parse.rs @@ -550,24 +550,6 @@ fn to_expr_report<'a>( } } - EExpr::BackpassArrow(pos) => { - let surroundings = Region::new(start, *pos); - let region = LineColumnRegion::from_pos(lines.convert_pos(*pos)); - - let doc = alloc.stack([ - alloc.reflow(r"I am partway through parsing an expression, but I got stuck here:"), - alloc.region_with_subregion(lines.convert_region(surroundings), region, severity), - alloc.concat([alloc.reflow("Looks like you are trying to define a function. ")]), - ]); - - Report { - filename, - doc, - title: "BAD BACKPASSING ARROW".to_string(), - severity, - } - } - EExpr::Record(erecord, pos) => { to_record_report(alloc, lines, filename, erecord, *pos, start) } @@ -704,8 +686,6 @@ fn to_expr_report<'a>( | EExpr::Equals(pos) | EExpr::DoubleColon(pos) | EExpr::MalformedPattern(pos) - | EExpr::BackpassComma(pos) - | EExpr::BackpassContinue(pos) | EExpr::DbgContinue(pos) | EExpr::Underscore(pos) | EExpr::Crash(pos) diff --git a/crates/reporting/src/error/type.rs b/crates/reporting/src/error/type.rs index 05f9aa0553a..bd9a17c5760 100644 --- a/crates/reporting/src/error/type.rs +++ b/crates/reporting/src/error/type.rs @@ -1457,7 +1457,7 @@ fn to_expr_report<'b>( alloc.concat([ alloc.note(""), alloc.reflow("Record builders need a mapper function before the "), - alloc.backpassing_arrow(), + alloc.backwards_arrow(), alloc.reflow(" to combine fields together with.") ]) } diff --git a/crates/reporting/src/report.rs b/crates/reporting/src/report.rs index b4385d10ba7..187fcecccfb 100644 --- a/crates/reporting/src/report.rs +++ b/crates/reporting/src/report.rs @@ -548,7 +548,7 @@ impl<'a> RocDocAllocator<'a> { self.text(name).annotate(Annotation::Shorthand) } - pub fn backpassing_arrow(&'a self) -> DocBuilder<'a, Self, Annotation> { + pub fn backwards_arrow(&'a self) -> DocBuilder<'a, Self, Annotation> { self.text("<-").annotate(Annotation::BinOp) } diff --git a/crates/test_compile/src/help_parse.rs b/crates/test_compile/src/help_parse.rs index 2a941b2ac34..901df4ae1e5 100644 --- a/crates/test_compile/src/help_parse.rs +++ b/crates/test_compile/src/help_parse.rs @@ -38,7 +38,7 @@ impl ParseExpr { let parser = skip_second( space0_before_optional_after( - loc_expr_block(true, false), + loc_expr_block(false), EExpr::IndentStart, EExpr::IndentEnd, ),