Skip to content

Commit

Permalink
fix: allow integer literals in struct field initializers for tuple st…
Browse files Browse the repository at this point in the history
…ructs
  • Loading branch information
amaanq committed Apr 7, 2024
1 parent c82ed80 commit 2e5682b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ module.exports = grammar({

field_initializer: $ => seq(
repeat($.attribute_item),
field('name', $._field_identifier),
field('field', choice($._field_identifier, $.integer_literal)),
':',
field('value', $._expression),
),
Expand Down
16 changes: 15 additions & 1 deletion test/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ NothingInMe {};
Point {x: 10.0, y: 20.0};
let a = SomeStruct { field1, field2: expression, field3, };
let u = game::User {name: "Joe", age: 35, score: 100_000};
let i = Instant { 0: Duration::from_millis(0) };

--------------------------------------------------------------------------------

Expand Down Expand Up @@ -484,7 +485,20 @@ let u = game::User {name: "Joe", age: 35, score: 100_000};
(integer_literal))
(field_initializer
(field_identifier)
(integer_literal))))))
(integer_literal)))))
(let_declaration
(identifier)
(struct_expression
(type_identifier)
(field_initializer_list
(field_initializer
(integer_literal)
(call_expression
(scoped_identifier
(identifier)
(identifier))
(arguments
(integer_literal))))))))

================================================================================
Struct expressions with update initializers
Expand Down

0 comments on commit 2e5682b

Please sign in to comment.