mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Implement &foo
record updater syntax sugar
This commit is contained in:
parent
a14a110293
commit
b1a972ab21
22 changed files with 302 additions and 41 deletions
|
@ -432,6 +432,9 @@ pub enum Expr<'a> {
|
|||
/// e.g. `.foo` or `.0`
|
||||
AccessorFunction(Accessor<'a>),
|
||||
|
||||
/// Update the value of a field in a record, e.g. `&foo`
|
||||
RecordUpdater(&'a str),
|
||||
|
||||
/// Look up exactly one field on a tuple, e.g. `(x, y).1`.
|
||||
TupleAccess(&'a Expr<'a>, &'a str),
|
||||
|
||||
|
@ -636,6 +639,7 @@ pub fn is_expr_suffixed(expr: &Expr) -> bool {
|
|||
Expr::SingleQuote(_) => false,
|
||||
Expr::RecordAccess(a, _) => is_expr_suffixed(a),
|
||||
Expr::AccessorFunction(_) => false,
|
||||
Expr::RecordUpdater(_) => false,
|
||||
Expr::TupleAccess(a, _) => is_expr_suffixed(a),
|
||||
Expr::List(items) => items.iter().any(|x| is_expr_suffixed(&x.value)),
|
||||
Expr::RecordUpdate { update, fields } => {
|
||||
|
@ -1024,6 +1028,7 @@ impl<'a, 'b> RecursiveValueDefIter<'a, 'b> {
|
|||
| Str(_)
|
||||
| SingleQuote(_)
|
||||
| AccessorFunction(_)
|
||||
| RecordUpdater(_)
|
||||
| Var { .. }
|
||||
| Underscore(_)
|
||||
| Crash
|
||||
|
@ -2487,6 +2492,7 @@ impl<'a> Malformed for Expr<'a> {
|
|||
Num(_) |
|
||||
NonBase10Int { .. } |
|
||||
AccessorFunction(_) |
|
||||
RecordUpdater(_) |
|
||||
Var { .. } |
|
||||
Underscore(_) |
|
||||
Tag(_) |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue