mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Support '??' syntax for optional record fields
This commit is contained in:
parent
3d4dd5b583
commit
a24fe430b4
21 changed files with 42 additions and 43 deletions
|
@ -2082,6 +2082,7 @@ pub fn merge_spaces<'a>(
|
|||
/// If the given Expr would parse the same way as a valid Pattern, convert it.
|
||||
/// Example: (foo) could be either an Expr::Var("foo") or Pattern::Identifier("foo")
|
||||
fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result<Pattern<'a>, ()> {
|
||||
println!("expr_to_pattern_help");
|
||||
let mut expr = expr.extract_spaces();
|
||||
|
||||
while let Expr::ParensAround(loc_expr) = &expr.item {
|
||||
|
@ -3587,7 +3588,10 @@ pub fn record_field<'a>() -> impl Parser<'a, RecordField<'a>, ERecord<'a>> {
|
|||
optional(either(
|
||||
and(byte(b':', ERecord::Colon), record_field_expr()),
|
||||
and(
|
||||
byte(b'?', ERecord::QuestionMark),
|
||||
and(
|
||||
byte(b'?', ERecord::QuestionMark),
|
||||
optional(byte(b'?', ERecord::QuestionMark)),
|
||||
),
|
||||
spaces_before(specialize_err_ref(ERecord::Expr, loc_expr(true))),
|
||||
),
|
||||
)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue