Skip to content

Commit

Permalink
fix: parse polyvariants starting with [| (#2781)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro authored Jul 29, 2024
1 parent d7e96a7 commit ff00dc4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/reason-parser/reason_parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -4646,6 +4646,7 @@ mark_position_typ
{ mktyp(Ptyp_constr($1, [])) }
| object_record_type
{ $1 }
| LBRACKETBAR row_field_list RBRACKET
| LBRACKET row_field_list RBRACKET
{ mktyp(Ptyp_variant ($2, Closed, None)) }
| LBRACKETGREATER loption(row_field_list) RBRACKET
Expand Down
8 changes: 8 additions & 0 deletions test/variants.t/input.re
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,11 @@ type widget_state = [
| `HOVER
| `ACTIVE
];

/* [| purposely without space */
type apiKeyError = [|`Dev |`Prod];

/* other polyvar variations */
type apiKeyError = [ | `Dev |`Prod];
type apiKeyError = [ `Dev |`Prod];

16 changes: 16 additions & 0 deletions test/variants.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,22 @@ Format variants
| `HOVER
| `ACTIVE
];

/* [| purposely without space */
type apiKeyError = [
| `Dev
| `Prod
];

/* other polyvar variations */
type apiKeyError = [
| `Dev
| `Prod
];
type apiKeyError = [
| `Dev
| `Prod
];
/* Doesn't work because we've correctly annotated parse tree nodes with explicit_arity! */
/* let notTupled: notTupleVariant = NotActuallyATuple intTuple; /*Doesn't work! */ */
/* Doesn't work because we've correctly annotated parse tree nodes with explicit_arity! */
Expand Down

0 comments on commit ff00dc4

Please sign in to comment.