From d8a7f85ead2b6f43368f51bfa8f7f23657db2f8a Mon Sep 17 00:00:00 2001 From: Aleksandr Kuzmenko Date: Fri, 22 Oct 2021 10:22:30 +0300 Subject: [PATCH] [typer] don't die when resolving overloads with not enough arguments closes #10434 --- extra/CHANGES.txt | 1 + src/codegen/overloads.ml | 3 +++ tests/misc/js/projects/Issue10434/Main.hx | 8 ++++++++ tests/misc/js/projects/Issue10434/compile-fail.hxml | 1 + .../misc/js/projects/Issue10434/compile-fail.hxml.stderr | 3 +++ 5 files changed, 16 insertions(+) create mode 100644 tests/misc/js/projects/Issue10434/Main.hx create mode 100644 tests/misc/js/projects/Issue10434/compile-fail.hxml create mode 100644 tests/misc/js/projects/Issue10434/compile-fail.hxml.stderr diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index b822553feb8..9695f929d0d 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -13,6 +13,7 @@ all : fixed errors on final vars modification with `+=`, `*=` etc operations (#10325) all : fixed hanging of MainLoop.add on threaded targets (#10308, #10329) + all : fixed compiler crash when resolving overloads with not enough arguments (#10434) display : improved code completion in anonymous objects declarations (#10414) js : fixed IntMap for keys greater than 2^31 (#10316) js : workaround to fix sourcemaps on Firefox in Windows (#10217) diff --git a/src/codegen/overloads.ml b/src/codegen/overloads.ml index ffd030306e5..11aeaaa3d42 100644 --- a/src/codegen/overloads.ml +++ b/src/codegen/overloads.ml @@ -269,6 +269,9 @@ struct acc @ rates | e :: elist, (n,o,t) :: args -> mk_rate ((rate_arg t e) :: acc) elist args + | [],_ -> + (* this can happen on pf_pad_nulls = false targets, see #10434 *) + acc | _ -> die "" __LOC__ in diff --git a/tests/misc/js/projects/Issue10434/Main.hx b/tests/misc/js/projects/Issue10434/Main.hx new file mode 100644 index 00000000000..e7307756034 --- /dev/null +++ b/tests/misc/js/projects/Issue10434/Main.hx @@ -0,0 +1,8 @@ +extern class ToolCache { + overload static function extractTar(?flags:Array):Void; + overload static function extractTar(?flags:String):Void; +} + +function main() { + ToolCache.extractTar(); +} \ No newline at end of file diff --git a/tests/misc/js/projects/Issue10434/compile-fail.hxml b/tests/misc/js/projects/Issue10434/compile-fail.hxml new file mode 100644 index 00000000000..a13a821bd35 --- /dev/null +++ b/tests/misc/js/projects/Issue10434/compile-fail.hxml @@ -0,0 +1 @@ +--run Main diff --git a/tests/misc/js/projects/Issue10434/compile-fail.hxml.stderr b/tests/misc/js/projects/Issue10434/compile-fail.hxml.stderr new file mode 100644 index 00000000000..b4b9a84028f --- /dev/null +++ b/tests/misc/js/projects/Issue10434/compile-fail.hxml.stderr @@ -0,0 +1,3 @@ +Main.hx:7: characters 2-24 : Ambiguous overload, candidates follow +Main.hx:2: characters 27-37 : ... (?flags : Null>) -> Void +Main.hx:3: characters 27-37 : ... (?flags : Null) -> Void \ No newline at end of file