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 dc8bd41 commit 57517be
Show file tree
Hide file tree
Showing 11 changed files with 5,215 additions and 5,243 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 @@ -520,6 +520,7 @@ module.exports = function defineGrammar(dialect) {
),

_type: $ => choice(
$._types,
$.union_type,
$.intersection_type,
$.disjunctive_normal_form_type,
Expand All @@ -543,14 +544,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 57517be

Please sign in to comment.