فهرست منبع

[typer] don't die when resolving overloads with not enough arguments

closes #10434
Aleksandr Kuzmenko 3 سال پیش
والد
کامیت
d8a7f85ead

+ 1 - 0
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)

+ 3 - 0
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
 

+ 8 - 0
tests/misc/js/projects/Issue10434/Main.hx

@@ -0,0 +1,8 @@
+extern class ToolCache {
+	overload static function extractTar(?flags:Array<String>):Void;
+	overload static function extractTar(?flags:String):Void;
+}
+
+function main() {
+	ToolCache.extractTar();
+}

+ 1 - 0
tests/misc/js/projects/Issue10434/compile-fail.hxml

@@ -0,0 +1 @@
+--run Main

+ 3 - 0
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<Array<String>>) -> Void
+Main.hx:3: characters 27-37 : ... (?flags : Null<String>) -> Void