diff --git a/src/core/tPrinting.ml b/src/core/tPrinting.ml index 8af1966d482..430083e580c 100644 --- a/src/core/tPrinting.ml +++ b/src/core/tPrinting.ml @@ -111,6 +111,7 @@ and s_constraint = function | MField cf -> Printf.sprintf "MField %s" cf.cf_name | MType(t,_) -> Printf.sprintf "MType %s" (s_type_kind t) | MOpenStructure -> "MOpenStructure" + | MEmptyStructure -> "MEmptyStructure" let s_access is_read = function | AccNormal -> "default" diff --git a/src/core/tType.ml b/src/core/tType.ml index 9cf872a2b42..5615c701e45 100644 --- a/src/core/tType.ml +++ b/src/core/tType.ml @@ -53,6 +53,7 @@ and tmono_constraint = | MField of tclass_field | MType of t * string option | MOpenStructure + | MEmptyStructure and tmono_constraint_kind = | CUnknown diff --git a/src/core/tUnification.ml b/src/core/tUnification.ml index 0889ecf3bb6..ef16143ce4b 100644 --- a/src/core/tUnification.ml +++ b/src/core/tUnification.ml @@ -69,7 +69,7 @@ module Monomorph = struct (MField cf) :: l ) an.a_fields [] | TAnon _ -> - [MOpenStructure] + [MEmptyStructure] | _ -> [MType(t,name)] @@ -80,6 +80,7 @@ module Monomorph = struct let types = DynArray.create () in let fields = ref PMap.empty in let is_open = ref false in + let is_empty = ref false in let rec check constr = match constr with | MMono(m2,name) -> begin match m2.tm_type with @@ -94,12 +95,16 @@ module Monomorph = struct DynArray.add types (t2,name) | MOpenStructure -> is_open := true + | MEmptyStructure -> + is_empty := true; in List.iter check m.tm_constraints; if DynArray.length types > 0 then CTypes (DynArray.to_list types) else if not (PMap.is_empty !fields) || !is_open then CStructural(!fields,!is_open) + else if !is_empty then + CStructural(PMap.empty,true) else CUnknown diff --git a/tests/unit/src/unit/issues/Issue9593.hx b/tests/unit/src/unit/issues/Issue9593.hx new file mode 100644 index 00000000000..41c672fc6dc --- /dev/null +++ b/tests/unit/src/unit/issues/Issue9593.hx @@ -0,0 +1,11 @@ +package unit.issues; +import unit.Test; + +class Issue9593 extends Test { + function test() { + foo(function(res) res.error); + utest.Assert.pass(); + } + + static function foo(cb:T->Void):Void {} +}