@@ -378,7 +378,9 @@ def parse(tokens: typing.List[Token], p: float = 0) -> "Object":
378378 # we can match variants in MatchFunction
379379 # It needs to be higher than the precedence of the && operator so that
380380 # we can use #true() and #false() in boolean expressions
381- l = Variant (token .value , parse (tokens , PS ["&&" ].pr + 1 ))
381+ # It needs to be higher than the precedence of juxtaposition so that
382+ # f #true() #false() is parsed as f(TRUE)(FALSE)
383+ l = Variant (token .value , parse (tokens , PS ["" ].pr + 1 ))
382384 elif isinstance (token , BytesLit ):
383385 base = token .base
384386 if base == 85 :
@@ -2272,6 +2274,18 @@ def test_parse_record_with_trailing_comma_raises_parse_error(self) -> None:
22722274 def test_parse_variant_returns_variant (self ) -> None :
22732275 self .assertEqual (parse ([VariantToken ("abc" ), IntLit (1 )]), Variant ("abc" , Int (1 )))
22742276
2277+ def test_match_with_variant (self ) -> None :
2278+ ast = parse (tokenize ("| #true () -> 123" ))
2279+ self .assertEqual (ast , MatchFunction ([MatchCase (TRUE , Int (123 ))]))
2280+
2281+ def test_binary_and_with_variant_args (self ) -> None :
2282+ ast = parse (tokenize ("#true() && #false()" ))
2283+ self .assertEqual (ast , Binop (BinopKind .BOOL_AND , TRUE , FALSE ))
2284+
2285+ def test_apply_with_variant_args (self ) -> None :
2286+ ast = parse (tokenize ("f #true() #false()" ))
2287+ self .assertEqual (ast , Apply (Apply (Var ("f" ), TRUE ), FALSE ))
2288+
22752289
22762290class MatchTests (unittest .TestCase ):
22772291 def test_match_hole_with_non_hole_returns_none (self ) -> None :
0 commit comments