Browse Source

fail nicer if unify_min can't find a common type

closes #11684
Simon Krajewski 1 year ago
parent
commit
cc105eb855

+ 1 - 1
src/core/tUnification.ml

@@ -1271,7 +1271,7 @@ module UnifyMinT = struct
 				begin match common_types with
 				| [] ->
 					begin match !first_error with
-					| None -> die "" __LOC__
+					| None -> UnifyMinError([Unify_custom "Could not determine common type, please add a type-hint"],0)
 					| Some(l,p) -> UnifyMinError(l,p)
 					end
 				| hd :: _ ->

+ 5 - 0
tests/misc/projects/Issue11684/Main.hx

@@ -0,0 +1,5 @@
+function test(input) {
+    return (input is Array) ? input[0] : input;
+}
+
+function main() {}

+ 2 - 0
tests/misc/projects/Issue11684/compile-fail.hxml

@@ -0,0 +1,2 @@
+--main Main
+--interp

+ 1 - 0
tests/misc/projects/Issue11684/compile-fail.hxml.stderr

@@ -0,0 +1 @@
+Main.hx:2: characters 42-47 : Could not determine common type, please add a type-hint