Fix bug where only first type of argument checked
This commit is contained in:
parent
a0791f97ad
commit
74a4af9c33
1 changed files with 16 additions and 9 deletions
25
eval.ml
25
eval.ml
|
@ -241,18 +241,25 @@ module External = struct
|
||||||
end
|
end
|
||||||
|
|
||||||
let find_operator op ts =
|
let find_operator op ts =
|
||||||
let filter t =
|
let open List in
|
||||||
List.filter (fun (ts, _) ->
|
let filter_type t i =
|
||||||
match ts with [] -> false | x::_ -> t=x)
|
filter (fun (ts, _) ->
|
||||||
|
nth_opt ts i
|
||||||
|
|> Option.map ((=) t)
|
||||||
|
|> Option.value ~default: false)
|
||||||
in
|
in
|
||||||
let rec aux ops = function
|
let rec aux ops i = function
|
||||||
| [] -> List.nth_opt ops 0
|
| [] ->
|
||||||
|
ops
|
||||||
|
|> filter (fun (ts, _) -> length ts = i)
|
||||||
|
|> Fun.flip nth_opt 0
|
||||||
| t::ts ->
|
| t::ts ->
|
||||||
(match aux (filter t ops) ts with
|
(match aux (filter_type t i ops) (i+1) ts with
|
||||||
| None -> Option.bind (Type.supertype t) (fun t -> aux ops (t::ts))
|
| None -> Option.bind (Type.supertype t)
|
||||||
| Some _ as x -> x)
|
(fun t -> aux ops i (t::ts))
|
||||||
|
| Some _ as x -> x)
|
||||||
in
|
in
|
||||||
aux (Operator.get op) ts
|
aux (Operator.get op) 0 ts
|
||||||
|
|
||||||
let promote_values =
|
let promote_values =
|
||||||
let rec promote_until t v =
|
let rec promote_until t v =
|
||||||
|
|
Loading…
Add table
Reference in a new issue