Fix not properly handling function types as arguments.

This commit is contained in:
Sander Spies 2020-06-05 10:47:23 +02:00
parent 57caa4ea85
commit a952cc496d
5 changed files with 22 additions and 13 deletions

View File

@ -430,7 +430,18 @@ type_expr_simple:
TProd {region = cover $1 $3; value=$2} TProd {region = cover $1 $3; value=$2}
} }
| "(" type_expr_simple "=>" type_expr_simple ")" { | "(" type_expr_simple "=>" type_expr_simple ")" {
TFun {region = cover $1 $5; value=$2,$3,$4} } TPar {
value = {
lpar = $1;
rpar = $5;
inside = TFun {
region = cover (type_expr_to_region $2) (type_expr_to_region $4);
value=$2,$3,$4
}
};
region = cover $1 $5;
}
}
type_annotation_simple: type_annotation_simple:
":" type_expr_simple { $1,$2 } ":" type_expr_simple { $1,$2 }

View File

@ -50,10 +50,7 @@ and pp_let_binding let_ (binding : let_binding) =
| Some (_,e) -> | Some (_,e) ->
patterns ^^ group (break 0 ^^ string ": " ^^ pp_type_expr e ^^ string " = ") patterns ^^ group (break 0 ^^ string ": " ^^ pp_type_expr e ^^ string " = ")
in in
match let_rhs with let rhs = pp_expr let_rhs
(* | EFun { } -> *)
| e ->
let rhs = pp_expr e
in prefix 2 0 lhs rhs in prefix 2 0 lhs rhs
and pp_pattern = function and pp_pattern = function
@ -403,7 +400,7 @@ and pp_seq {value; _} =
and pp_type_expr = function and pp_type_expr = function
TProd t -> pp_cartesian t TProd t -> pp_cartesian t
| TSum t -> pp_variants t | TSum t -> break 0 ^^ pp_variants t
| TRecord t -> pp_fields t | TRecord t -> pp_fields t
| TApp t -> pp_type_app t | TApp t -> pp_type_app t
| TFun t -> pp_fun_type t | TFun t -> pp_fun_type t

View File

@ -3,12 +3,12 @@ let foobar =
{ {
let foo: int => int = (i: int) => i; let foo: int => int = (i: int) => i;
let bar: ((int => int) => int) = let bar: ((int => int) => int) =
(f: int => int) => f(i); (f: (int => int)) => f(i);
bar(foo) bar(foo)
}; };
let higher2 = let higher2 =
(i: int, f: int => int): int => (i: int, f: (int => int)): int =>
{ {
let ii: int = f(i); let ii: int = f(i);
ii ii
@ -37,7 +37,7 @@ let g = (i: int): int => f(i);
let foobar4 = (i: int): int => g(g(i)); let foobar4 = (i: int): int => g(g(i));
let higher3 = let higher3 =
(i: int, f: int => int, g: int => int): int => (i: int, f: (int => int), g: (int => int)): int =>
{ {
let ii: int = f(g(i)); let ii: int = f(g(i));
ii ii

View File

@ -2,4 +2,4 @@ type storage = unit;
let main = let main =
((a, s): (unit, storage)): unit => ((a, s): (unit, storage)): unit =>
((f: unit => unit) => f(()))((useless: unit) => unit); ((f: (unit => unit)) => f(()))((useless: unit) => unit);

View File

@ -1,6 +1,7 @@
type storage = address; type storage = address;
type parameter = Donate(unit) type parameter =
Donate(unit)
| Distribute((unit => list(operation))); | Distribute((unit => list(operation)));
let donate = let donate =
@ -10,7 +11,7 @@ let donate =
}; };
let distribute = let distribute =
((p, s): (unit => list(operation), storage)) ((p, s): ((unit => list(operation)), storage))
: :
(list(operation), storage) => (list(operation), storage) =>
{ {