mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 20:28:02 +00:00
Remove old record builder syntax
This commit is contained in:
parent
9678046d91
commit
2da08be8ef
20 changed files with 57 additions and 2280 deletions
|
@ -4972,30 +4972,6 @@ mod test_reporting {
|
|||
"###
|
||||
);
|
||||
|
||||
test_report!(
|
||||
record_builder_in_module_params,
|
||||
indoc!(
|
||||
r"
|
||||
import Menu {
|
||||
echo,
|
||||
name: <- applyName
|
||||
}
|
||||
"
|
||||
),@r###"
|
||||
── OLD-STYLE RECORD BUILDER IN MODULE PARAMS in ...r_in_module_params/Test.roc ─
|
||||
|
||||
I was partway through parsing module params, but I got stuck here:
|
||||
|
||||
4│ import Menu {
|
||||
5│ echo,
|
||||
6│ name: <- applyName
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This looks like an old-style record builder field, but those are not
|
||||
allowed in module params.
|
||||
"###
|
||||
);
|
||||
|
||||
test_report!(
|
||||
record_update_in_module_params,
|
||||
indoc!(
|
||||
|
@ -10661,163 +10637,6 @@ All branches in an `if` must have the same type!
|
|||
|
||||
// Record Builders
|
||||
|
||||
test_report!(
|
||||
optional_field_in_old_record_builder,
|
||||
indoc!(
|
||||
r#"
|
||||
{
|
||||
a: <- apply "a",
|
||||
b,
|
||||
c ? "optional"
|
||||
}
|
||||
"#
|
||||
),
|
||||
@r#"
|
||||
── BAD OLD-STYLE RECORD BUILDER in ...nal_field_in_old_record_builder/Test.roc ─
|
||||
|
||||
I am partway through parsing a record builder, and I found an optional
|
||||
field:
|
||||
|
||||
1│ app "test" provides [main] to "./platform"
|
||||
2│
|
||||
3│ main =
|
||||
4│ {
|
||||
5│ a: <- apply "a",
|
||||
6│ b,
|
||||
7│ c ? "optional"
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
Optional fields can only appear when you destructure a record.
|
||||
"#
|
||||
);
|
||||
|
||||
test_report!(
|
||||
record_update_old_builder,
|
||||
indoc!(
|
||||
r#"
|
||||
{ rec &
|
||||
a: <- apply "a",
|
||||
b: 3
|
||||
}
|
||||
"#
|
||||
),
|
||||
@r#"
|
||||
── BAD RECORD UPDATE in tmp/record_update_old_builder/Test.roc ─────────────────
|
||||
|
||||
I am partway through parsing a record update, and I found an old-style
|
||||
record builder field:
|
||||
|
||||
1│ app "test" provides [main] to "./platform"
|
||||
2│
|
||||
3│ main =
|
||||
4│ { rec &
|
||||
5│ a: <- apply "a",
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Old-style record builders cannot be updated like records.
|
||||
"#
|
||||
);
|
||||
|
||||
test_report!(
|
||||
multiple_old_record_builders,
|
||||
indoc!(
|
||||
r#"
|
||||
succeed
|
||||
{ a: <- apply "a" }
|
||||
{ b: <- apply "b" }
|
||||
"#
|
||||
),
|
||||
@r#"
|
||||
── MULTIPLE OLD-STYLE RECORD BUILDERS in /code/proj/Main.roc ───────────────────
|
||||
|
||||
This function is applied to multiple old-style record builders:
|
||||
|
||||
4│> succeed
|
||||
5│> { a: <- apply "a" }
|
||||
6│> { b: <- apply "b" }
|
||||
|
||||
Note: Functions can only take at most one old-style record builder!
|
||||
|
||||
Tip: You can combine them or apply them separately.
|
||||
"#
|
||||
);
|
||||
|
||||
test_report!(
|
||||
unapplied_old_record_builder,
|
||||
indoc!(
|
||||
r#"
|
||||
{ a: <- apply "a" }
|
||||
"#
|
||||
),
|
||||
@r#"
|
||||
── UNAPPLIED OLD-STYLE RECORD BUILDER in /code/proj/Main.roc ───────────────────
|
||||
|
||||
This old-style record builder was not applied to a function:
|
||||
|
||||
4│ { a: <- apply "a" }
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
However, we need a function to construct the record.
|
||||
|
||||
Note: Functions must be applied directly. The pipe operator (|>) cannot be used.
|
||||
"#
|
||||
);
|
||||
|
||||
test_report!(
|
||||
old_record_builder_apply_non_function,
|
||||
indoc!(
|
||||
r#"
|
||||
succeed = \_ -> crash ""
|
||||
|
||||
succeed {
|
||||
a: <- "a",
|
||||
}
|
||||
"#
|
||||
),
|
||||
@r#"
|
||||
── TOO MANY ARGS in /code/proj/Main.roc ────────────────────────────────────────
|
||||
|
||||
This value is not a function, but it was given 1 argument:
|
||||
|
||||
7│ a: <- "a",
|
||||
^^^
|
||||
|
||||
Tip: Remove <- to assign the field directly.
|
||||
"#
|
||||
);
|
||||
|
||||
// Skipping test because opaque types defined in the same module
|
||||
// do not fail with the special opaque type error
|
||||
//
|
||||
// test_report!(
|
||||
// record_builder_apply_opaque,
|
||||
// indoc!(
|
||||
// r#"
|
||||
// succeed = \_ -> crash ""
|
||||
|
||||
// Decode := {}
|
||||
|
||||
// get : Str -> Decode
|
||||
// get = \_ -> @Decode {}
|
||||
|
||||
// succeed {
|
||||
// a: <- get "a",
|
||||
// # missing |> apply ^
|
||||
// }
|
||||
// "#
|
||||
// ),
|
||||
// @r#"
|
||||
// ── TOO MANY ARGS in /code/proj/Main.roc ────────────────────────────────────────
|
||||
|
||||
// This value is an opaque type, so it cannot be called with an argument:
|
||||
|
||||
// 12│ a: <- get "a",
|
||||
// ^^^^^^^
|
||||
|
||||
// Hint: Did you mean to apply it to a function first?
|
||||
// "#
|
||||
// );
|
||||
|
||||
test_report!(
|
||||
empty_record_builder,
|
||||
indoc!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue