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
23
eval.ml
23
eval.ml
|
@ -241,18 +241,25 @@ module External = struct
|
|||
end
|
||||
|
||||
let find_operator op ts =
|
||||
let filter t =
|
||||
List.filter (fun (ts, _) ->
|
||||
match ts with [] -> false | x::_ -> t=x)
|
||||
let open List in
|
||||
let filter_type t i =
|
||||
filter (fun (ts, _) ->
|
||||
nth_opt ts i
|
||||
|> Option.map ((=) t)
|
||||
|> Option.value ~default: false)
|
||||
in
|
||||
let rec aux ops = function
|
||||
| [] -> List.nth_opt ops 0
|
||||
let rec aux ops i = function
|
||||
| [] ->
|
||||
ops
|
||||
|> filter (fun (ts, _) -> length ts = i)
|
||||
|> Fun.flip nth_opt 0
|
||||
| t::ts ->
|
||||
(match aux (filter t ops) ts with
|
||||
| None -> Option.bind (Type.supertype t) (fun t -> aux ops (t::ts))
|
||||
(match aux (filter_type t i ops) (i+1) ts with
|
||||
| None -> Option.bind (Type.supertype t)
|
||||
(fun t -> aux ops i (t::ts))
|
||||
| Some _ as x -> x)
|
||||
in
|
||||
aux (Operator.get op) ts
|
||||
aux (Operator.get op) 0 ts
|
||||
|
||||
let promote_values =
|
||||
let rec promote_until t v =
|
||||
|
|
Loading…
Add table
Reference in a new issue