File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ and eval_rec (term : term) (env : environment) : value =
24
24
| Closure (left_branches , left_env ) ->
25
25
let right_value = eval_rec right_term env in
26
26
let resolved_branch =
27
- resolve_branch left_branches (value_to_term right_value)
27
+ resolve_branch left_branches right_value
28
28
in
29
29
eval_rec resolved_branch (right_value :: left_env)
30
30
| VConst _ -> raise (Invalid_argument " Cannot apply a constant" )
@@ -49,9 +49,11 @@ and eval_rec (term : term) (env : environment) : value =
49
49
50
50
(* Determines the branch of the abstraction to execute, based on the type of the argument *)
51
51
and resolve_branch branches argument =
52
+ (* If there's only one branch, use it, since we assume type-checking confirmed type safety *)
53
+ if List. length branches = 1 then snd (List. hd branches) else
52
54
(* TODO: can I always associate a base type with arguments to guarantee I can determine
53
55
the appropriate branch, without needing to recompute each time? *)
54
- let argument_type = Option. get (get_type argument) in
56
+ let argument_type = Option. get (get_type (value_to_term argument) ) in
55
57
let _, resolved_branch =
56
58
List. find
57
59
(fun (branch_type , _ ) -> is_subtype argument_type branch_type)
You can’t perform that action at this time.
0 commit comments