Skip to content

Commit

Permalink
Fix variant constructor type in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3kk1d committed Nov 4, 2024
1 parent c3de67f commit ac4e9f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/haz3lmenhir/Parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ exp:
| f = FLOAT { Float f }
| v = IDENT { Var v }
| c = CONSTRUCTOR_IDENT { Constructor(c, UnknownType(Internal))}
| c = CONSTRUCTOR_IDENT; TILDE; t = typ; { Cast(Constructor(c, UnknownType(Internal)), UnknownType(Internal), t) }
| c = CONSTRUCTOR_IDENT; TILDE; t = typ; { Constructor(c, t) }
| c = CONSTRUCTOR_IDENT; COLON; t = typ; { Cast(Constructor(c, UnknownType(Internal)), UnknownType(Internal), t) }
| s = STRING { String s}
| OPEN_PAREN; e = exp; CLOSE_PAREN { e }
| OPEN_PAREN; e = exp; COMMA; l = separated_list(COMMA, exp); CLOSE_PAREN { TupleExp(e :: l) }
Expand Down
5 changes: 5 additions & 0 deletions test/Test_Menhir.re
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ let tests = [
Int |> Typ.fresh,
)
|> Exp.fresh,
"A : Int",
),
menhir_only_test(
"Constructor of specific sum type",
Constructor("A", Int |> Typ.fresh) |> Exp.fresh,
"A ~ Int",
),
parser_test(
Expand Down

0 comments on commit ac4e9f9

Please sign in to comment.