mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
commit
fc52bdc59a
771
Cargo.lock
generated
771
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -81,6 +81,7 @@ where
|
||||
let mut is_capitalized;
|
||||
let is_accessor_fn;
|
||||
let mut is_private_tag = false;
|
||||
let mut chars_parsed;
|
||||
|
||||
// Identifiers and accessor functions must start with either a letter or a dot.
|
||||
// If this starts with neither, it must be something else!
|
||||
@ -96,6 +97,8 @@ where
|
||||
is_private_tag = true;
|
||||
is_capitalized = true;
|
||||
is_accessor_fn = false;
|
||||
|
||||
chars_parsed = 2;
|
||||
}
|
||||
Some(ch) => {
|
||||
return Err(unexpected(ch, 0, state, Attempting::Identifier));
|
||||
@ -109,9 +112,13 @@ where
|
||||
|
||||
is_capitalized = ch.is_uppercase();
|
||||
is_accessor_fn = false;
|
||||
|
||||
chars_parsed = 1;
|
||||
} else if ch == '.' {
|
||||
is_capitalized = false;
|
||||
is_accessor_fn = true;
|
||||
|
||||
chars_parsed = 1;
|
||||
} else {
|
||||
return Err(unexpected(ch, 0, state, Attempting::Identifier));
|
||||
}
|
||||
@ -121,7 +128,6 @@ where
|
||||
}
|
||||
};
|
||||
|
||||
let mut chars_parsed = part_buf.len();
|
||||
let mut next_char = None;
|
||||
|
||||
while let Some(ch) = chars.next() {
|
||||
|
@ -3667,26 +3667,40 @@ mod test_reporting {
|
||||
)
|
||||
}
|
||||
|
||||
// TODO field accessors give a parse error at the moment
|
||||
// #[test]
|
||||
// fn optional_record_invalid_accessor() {
|
||||
// report_problem_as(
|
||||
// indoc!(
|
||||
// r#"
|
||||
// f : { x : Int, y ? Int } -> Int
|
||||
// f = \r -> .y r
|
||||
//
|
||||
// f
|
||||
// "#
|
||||
// ),
|
||||
// indoc!(
|
||||
// r#"
|
||||
// -- TYPE MISMATCH ---------------------------------------------------------------
|
||||
//
|
||||
// "#
|
||||
// ),
|
||||
// )
|
||||
// }
|
||||
#[test]
|
||||
fn optional_record_invalid_accessor() {
|
||||
report_problem_as(
|
||||
indoc!(
|
||||
r#"
|
||||
f : { x : Int, y ? Int } -> Int
|
||||
f = \r -> .y r
|
||||
|
||||
f
|
||||
"#
|
||||
),
|
||||
indoc!(
|
||||
r#"
|
||||
-- TYPE MISMATCH ---------------------------------------------------------------
|
||||
|
||||
The 1st argument to this function is not what I expect:
|
||||
|
||||
2 ┆ f = \r -> .y r
|
||||
┆ ^
|
||||
|
||||
This `r` value is a:
|
||||
|
||||
{ x : Int, y ? Int }
|
||||
|
||||
But this function needs the 1st argument to be:
|
||||
|
||||
{ x : Int, y : Int }
|
||||
|
||||
Hint: To extract the `.y` field it must be non-optional, but the type
|
||||
says this field is optional. Learn more about optional fields at TODO.
|
||||
"#
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn guard_mismatch_with_annotation() {
|
||||
|
Loading…
Reference in New Issue
Block a user