Skip to content

Commit

Permalink
feat(compiler)!: Remove support of single-argument tuples (#1608)
Browse files Browse the repository at this point in the history
chore(compiler): Fix typo in alias message
  • Loading branch information
phated authored Jan 24, 2023
1 parent 73c9499 commit 509cd85
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 270 deletions.
4 changes: 0 additions & 4 deletions compiler/src/formatting/format.re
Original file line number Diff line number Diff line change
Expand Up @@ -1784,10 +1784,6 @@ and print_type =
parsed_types,
),
),
switch (parsed_types) {
| [_one] => Doc.comma
| _ => Doc.nil
},
]),
),
Doc.softLine,
Expand Down
157 changes: 74 additions & 83 deletions compiler/src/parsing/parser.messages
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,55 @@ program: RECORD UIDENT LBRACE LIDENT COLON WHILE
## The known suffix of the stack is as follows:
## simple_id COLON
##
program: WASMI64 COLON LPAREN UIDENT COMMA EOL UIDENT COMMA EOL WHILE
##
## Ends in an error in state: 111.
##
## lseparated_nonempty_list_inner(comma,typ) -> lseparated_nonempty_list_inner(comma,typ) comma . typ [ RPAREN EOL COMMA ]
## tuple_typs -> typ COMMA eols lseparated_nonempty_list_inner(comma,typ) comma . [ RPAREN EOL ]
##
## The known suffix of the stack is as follows:
## typ COMMA eols lseparated_nonempty_list_inner(comma,typ) comma
##
## WARNING: This example involves spurious reductions.
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 5, spurious reduction of production eols -> nonempty_list(eol)
## In state 96, spurious reduction of production comma -> COMMA eols
##
program: WASMI64 COLON LPAREN UIDENT COMMA UIDENT COMMA EOL WHILE
##
## Ends in an error in state: 105.
##
## lseparated_nonempty_list_inner(comma,typ) -> lseparated_nonempty_list_inner(comma,typ) comma . typ [ RPAREN EOL COMMA ]
## tuple_typs -> typ COMMA lseparated_nonempty_list_inner(comma,typ) comma . [ RPAREN EOL ]
##
## The known suffix of the stack is as follows:
## typ COMMA lseparated_nonempty_list_inner(comma,typ) comma
##
## WARNING: This example involves spurious reductions.
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 5, spurious reduction of production eols -> nonempty_list(eol)
## In state 96, spurious reduction of production comma -> COMMA eols
##
program: WASMI64 COLON LPAREN UIDENT COMMA WHILE
##
## Ends in an error in state: 103.
##
## tuple_typs -> typ COMMA . [ RPAREN EOL ]
## tuple_typs -> typ COMMA . lseparated_nonempty_list_inner(comma,typ) [ RPAREN EOL ]
## tuple_typs -> typ COMMA . lseparated_nonempty_list_inner(comma,typ) comma [ RPAREN EOL ]
## tuple_typs -> typ COMMA . eols lseparated_nonempty_list_inner(comma,typ) [ RPAREN EOL ]
## tuple_typs -> typ COMMA . eols lseparated_nonempty_list_inner(comma,typ) comma [ RPAREN EOL ]
##
## The known suffix of the stack is as follows:
## typ COMMA
##

Expected a type.

Expand Down Expand Up @@ -2882,7 +2931,7 @@ program: IMPORT LBRACE UIDENT THICKARROW
## In state 129, spurious reduction of production id -> lseparated_nonempty_list_inner(dot,type_id_str)
##

Expected an alias like`as foo`, a comma followed by another identifier, or `}` to complete the block.
Expected an alias like `as foo`, a comma followed by another identifier, or `}` to complete the block.

program: IMPORT LBRACE WHILE
##
Expand Down Expand Up @@ -3847,6 +3896,30 @@ program: LET NUMBER_INT PIPE EOL WHILE
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 5, spurious reduction of production eols -> nonempty_list(eol)
##
program: LPAREN WASMI64 COMMA WHEN
##
## Ends in an error in state: 520.
##
## tuple_exprs -> expr COMMA . [ RPAREN EOL ]
## tuple_exprs -> expr COMMA . lseparated_nonempty_list_inner(comma,expr) option(comma) [ RPAREN EOL ]
## tuple_exprs -> expr COMMA . eols lseparated_nonempty_list_inner(comma,expr) option(comma) [ RPAREN EOL ]
##
## The known suffix of the stack is as follows:
## expr COMMA
##
program: LET LPAREN WASMI64 COMMA WHILE
##
## Ends in an error in state: 382.
##
## tuple_patterns -> pattern COMMA . [ RPAREN EOL ]
## tuple_patterns -> pattern COMMA . lseparated_nonempty_list_inner(comma,pattern) [ RPAREN EOL ]
## tuple_patterns -> pattern COMMA . lseparated_nonempty_list_inner(comma,pattern) comma [ RPAREN EOL ]
## tuple_patterns -> pattern COMMA . eols lseparated_nonempty_list_inner(comma,pattern) [ RPAREN EOL ]
## tuple_patterns -> pattern COMMA . eols lseparated_nonempty_list_inner(comma,pattern) comma [ RPAREN EOL ]
##
## The known suffix of the stack is as follows:
## pattern COMMA
##

Expected a pattern.

Expand Down Expand Up @@ -4142,22 +4215,6 @@ program: LET LPAREN WASMI64 COMMA WASMI64 RBRACK

Expected a comma followed by another pattern or `)` to complete the tuple pattern.

program: LET LPAREN WASMI64 COMMA WHILE
##
## Ends in an error in state: 382.
##
## tuple_patterns -> pattern COMMA . [ RPAREN EOL ]
## tuple_patterns -> pattern COMMA . lseparated_nonempty_list_inner(comma,pattern) [ RPAREN EOL ]
## tuple_patterns -> pattern COMMA . lseparated_nonempty_list_inner(comma,pattern) comma [ RPAREN EOL ]
## tuple_patterns -> pattern COMMA . eols lseparated_nonempty_list_inner(comma,pattern) [ RPAREN EOL ]
## tuple_patterns -> pattern COMMA . eols lseparated_nonempty_list_inner(comma,pattern) comma [ RPAREN EOL ]
##
## The known suffix of the stack is as follows:
## pattern COMMA
##

Expected a pattern or an immediate `)` for a single-argument tuple pattern.

program: LET LPAREN WASMI64 WHILE
##
## Ends in an error in state: 381.
Expand Down Expand Up @@ -4418,20 +4475,6 @@ program: LPAREN WASMI64 COMMA WASMI64 THICKARROW

Expected a comma followed by an expression or `)` to complete the tuple expression.

program: LPAREN WASMI64 COMMA WHEN
##
## Ends in an error in state: 520.
##
## tuple_exprs -> expr COMMA . [ RPAREN EOL ]
## tuple_exprs -> expr COMMA . lseparated_nonempty_list_inner(comma,expr) option(comma) [ RPAREN EOL ]
## tuple_exprs -> expr COMMA . eols lseparated_nonempty_list_inner(comma,expr) option(comma) [ RPAREN EOL ]
##
## The known suffix of the stack is as follows:
## expr COMMA
##

Expected an expression or `)` for a single-argument tuple.

program: LPAREN WASMI64 EOL WHILE
##
## Ends in an error in state: 113.
Expand Down Expand Up @@ -5883,58 +5926,6 @@ program: WASMI64 COLON FUN WHILE
# This error can't appear as the FUN token wouldn't have been injected.
Expected an identifier for a single-argument function or a comma-separated list of types surrounded by `(`/`)`.

program: WASMI64 COLON LPAREN UIDENT COMMA EOL UIDENT COMMA EOL WHILE
##
## Ends in an error in state: 111.
##
## lseparated_nonempty_list_inner(comma,typ) -> lseparated_nonempty_list_inner(comma,typ) comma . typ [ RPAREN EOL COMMA ]
## tuple_typs -> typ COMMA eols lseparated_nonempty_list_inner(comma,typ) comma . [ RPAREN EOL ]
##
## The known suffix of the stack is as follows:
## typ COMMA eols lseparated_nonempty_list_inner(comma,typ) comma
##
## WARNING: This example involves spurious reductions.
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 5, spurious reduction of production eols -> nonempty_list(eol)
## In state 96, spurious reduction of production comma -> COMMA eols
##
program: WASMI64 COLON LPAREN UIDENT COMMA UIDENT COMMA EOL WHILE
##
## Ends in an error in state: 105.
##
## lseparated_nonempty_list_inner(comma,typ) -> lseparated_nonempty_list_inner(comma,typ) comma . typ [ RPAREN EOL COMMA ]
## tuple_typs -> typ COMMA lseparated_nonempty_list_inner(comma,typ) comma . [ RPAREN EOL ]
##
## The known suffix of the stack is as follows:
## typ COMMA lseparated_nonempty_list_inner(comma,typ) comma
##
## WARNING: This example involves spurious reductions.
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 5, spurious reduction of production eols -> nonempty_list(eol)
## In state 96, spurious reduction of production comma -> COMMA eols
##
program: WASMI64 COLON LPAREN UIDENT COMMA WHILE
##
## Ends in an error in state: 103.
##
## tuple_typs -> typ COMMA . [ RPAREN EOL ]
## tuple_typs -> typ COMMA . lseparated_nonempty_list_inner(comma,typ) [ RPAREN EOL ]
## tuple_typs -> typ COMMA . lseparated_nonempty_list_inner(comma,typ) comma [ RPAREN EOL ]
## tuple_typs -> typ COMMA . eols lseparated_nonempty_list_inner(comma,typ) [ RPAREN EOL ]
## tuple_typs -> typ COMMA . eols lseparated_nonempty_list_inner(comma,typ) comma [ RPAREN EOL ]
##
## The known suffix of the stack is as follows:
## typ COMMA
##

Expected a type or an immediate `)` to complete the tuple type.

program: WASMI64 COLON LPAREN UIDENT COMMA EOL UIDENT WHEN
##
## Ends in an error in state: 110.
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/parsing/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ patterns:
| ioption(eols) lseparated_nonempty_list(comma, pattern) ioption(comma) { $2 }

tuple_patterns:
| pattern COMMA ioption(tuple_pattern_ending) { $1::(Option.value ~default:[] $3) }
| pattern COMMA tuple_pattern_ending { $1::$3 }

record_patterns:
| lseparated_nonempty_list(comma, record_pattern) comma? { $1 }
Expand Down Expand Up @@ -301,7 +301,7 @@ typs:
| ioption(eols) lseparated_nonempty_list(comma, typ) ioption(comma) { $2 }

tuple_typs:
| typ COMMA ioption(tuple_typ_ending) { $1::(Option.value ~default:[] $3) }
| typ COMMA tuple_typ_ending { $1::$3 }

value_bind:
| pattern equal expr { Vb.mk ~loc:(to_loc $loc) $1 $3 }
Expand Down Expand Up @@ -573,7 +573,7 @@ block_body_expr:
| ioption(eols) lseparated_nonempty_list(comma, expr) comma? { $2 }

tuple_exprs:
| expr COMMA ioption(tuple_expr_ending) { $1::(Option.value ~default:[] $3) }
| expr COMMA tuple_expr_ending { $1::$3 }

array_get:
| left_accessor_expr lbrack expr rbrack { Exp.array_get ~loc:(to_loc $loc) $1 $3 }
Expand Down
3 changes: 0 additions & 3 deletions compiler/src/typed/oprint.re
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,6 @@ and print_out_type_2 = ppf =>
print_typlist(print_simple_out_type, ","),
tyl,
);
if (List.length(tyl) == 1) {
pp_print_char(ppf, ',');
};
pp_print_char(ppf, ')');
pp_close_box(ppf, ());
}
Expand Down
71 changes: 0 additions & 71 deletions compiler/test/__snapshots__/tuples.2f6e820d.0.snapshot

This file was deleted.

71 changes: 0 additions & 71 deletions compiler/test/__snapshots__/tuples.843a836f.0.snapshot

This file was deleted.

Loading

0 comments on commit 509cd85

Please sign in to comment.