Browse Source

print missing argument names and types (closes #3802)

Simon Krajewski 10 years ago
parent
commit
e06f66ad5c

+ 1 - 0
tests/misc/compile.hxml

@@ -1,2 +1,3 @@
 -cp src
+#-D MISC_TEST_FILTER=3802
 --run Main

+ 7 - 0
tests/misc/projects/Issue3802/Main.hx

@@ -0,0 +1,7 @@
+class Main {
+	static function main() {
+		test();
+	}
+
+	static function test(i:Int, s:String) { }
+}

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

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

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

@@ -0,0 +1 @@
+Main.hx:3: characters 2-8 : Not enough arguments, expected i:Int, s:String

+ 4 - 2
typecore.ml

@@ -125,7 +125,7 @@ and typer = {
 }
 
 type call_error =
-	| Not_enough_arguments
+	| Not_enough_arguments of (string * bool * t) list
 	| Too_many_arguments
 	| Could_not_unify of error_msg
 	| Cannot_skip_non_nullable of string
@@ -266,7 +266,9 @@ let rec error_msg = function
 	| Call_error err -> s_call_error err
 
 and s_call_error = function
-	| Not_enough_arguments -> "Not enough arguments"
+	| Not_enough_arguments tl ->
+		let pctx = print_context() in
+		"Not enough arguments, expected " ^ (String.concat ", " (List.map (fun (n,_,t) -> n ^ ":" ^ (short_type pctx t)) tl))
 	| Too_many_arguments -> "Too many arguments"
 	| Could_not_unify err -> error_msg err
 	| Cannot_skip_non_nullable s -> "Cannot skip non-nullable argument " ^ s

+ 1 - 1
typer.ml

@@ -713,7 +713,7 @@ let rec unify_call_args' ctx el args r callp inline force_inline =
 					assert false
 			end
 		| [],(_,false,_) :: _ ->
-			call_error Not_enough_arguments callp
+			call_error (Not_enough_arguments args) callp
 		| [],(name,true,t) :: args ->
 			begin match loop [] args with
 				| [] when not (inline && (ctx.g.doinline || force_inline)) && not ctx.com.config.pf_pad_nulls ->