Skip to content

Commit

Permalink
fix: fix single types being incorrectly parsed as union_type
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdw committed Jan 24, 2024
1 parent 0d931c1 commit 5108ebe
Show file tree
Hide file tree
Showing 11 changed files with 4,356 additions and 4,384 deletions.
9 changes: 5 additions & 4 deletions common/define-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports = function defineGrammar(dialect) {
[$._array_destructing_element, $.array_element_initializer],
[$._primary_expression, $._array_destructing_element],

[$.union_type, $.intersection_type, $.disjunctive_normal_form_type],
[$._type, $.union_type, $.intersection_type, $.disjunctive_normal_form_type],
[$.union_type, $.disjunctive_normal_form_type],
[$.intersection_type],
[$.if_statement],
Expand Down Expand Up @@ -519,6 +519,7 @@ module.exports = function defineGrammar(dialect) {
),

_type: $ => choice(
$._types,
$.union_type,
$.intersection_type,
$.disjunctive_normal_form_type,
Expand All @@ -542,14 +543,14 @@ module.exports = function defineGrammar(dialect) {

bottom_type: _ => 'never',

union_type: $ => prec.dynamic(1, pipeSep1($._types)),
union_type: $ => pipeSep1($._types),

intersection_type: $ => ampSep1($._types),

disjunctive_normal_form_type: $ => pipeSep1(choice(
disjunctive_normal_form_type: $ => prec.dynamic(-1, pipeSep1(choice(
seq('(', $.intersection_type, ')'),
$._types,
)),
))),

primitive_type: _ => choice(
'array',
Expand Down
Loading

0 comments on commit 5108ebe

Please sign in to comment.