From cc105eb8558be55f666882c1e2796007573f39d7 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Tue, 4 Jun 2024 13:15:28 +0200 Subject: [PATCH] fail nicer if unify_min can't find a common type closes #11684 --- src/core/tUnification.ml | 2 +- tests/misc/projects/Issue11684/Main.hx | 5 +++++ tests/misc/projects/Issue11684/compile-fail.hxml | 2 ++ tests/misc/projects/Issue11684/compile-fail.hxml.stderr | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/misc/projects/Issue11684/Main.hx create mode 100644 tests/misc/projects/Issue11684/compile-fail.hxml create mode 100644 tests/misc/projects/Issue11684/compile-fail.hxml.stderr diff --git a/src/core/tUnification.ml b/src/core/tUnification.ml index e372c151b15..eaadf2cca64 100644 --- a/src/core/tUnification.ml +++ b/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 :: _ -> diff --git a/tests/misc/projects/Issue11684/Main.hx b/tests/misc/projects/Issue11684/Main.hx new file mode 100644 index 00000000000..25ba4751605 --- /dev/null +++ b/tests/misc/projects/Issue11684/Main.hx @@ -0,0 +1,5 @@ +function test(input) { + return (input is Array) ? input[0] : input; +} + +function main() {} diff --git a/tests/misc/projects/Issue11684/compile-fail.hxml b/tests/misc/projects/Issue11684/compile-fail.hxml new file mode 100644 index 00000000000..b30a755894b --- /dev/null +++ b/tests/misc/projects/Issue11684/compile-fail.hxml @@ -0,0 +1,2 @@ +--main Main +--interp \ No newline at end of file diff --git a/tests/misc/projects/Issue11684/compile-fail.hxml.stderr b/tests/misc/projects/Issue11684/compile-fail.hxml.stderr new file mode 100644 index 00000000000..f8faedf6a69 --- /dev/null +++ b/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 \ No newline at end of file