瀏覽代碼

[typer] remove "for function argument" errors

closes #9581
Simon Krajewski 5 年之前
父節點
當前提交
48d5e79f8c
共有 29 個文件被更改,包括 31 次插入65 次删除
  1. 6 7
      src/typing/calls.ml
  2. 1 2
      tests/misc/projects/Issue1310/compile1-fail.hxml.stderr
  3. 1 2
      tests/misc/projects/Issue2148/compile1-fail.hxml.stderr
  4. 1 2
      tests/misc/projects/Issue2232/compile1-fail.hxml.stderr
  5. 1 2
      tests/misc/projects/Issue3781/compile-fail.hxml.stderr
  6. 1 2
      tests/misc/projects/Issue4540/compile-fail.hxml.stderr
  7. 0 1
      tests/misc/projects/Issue4775/compile1-fail.hxml.stderr
  8. 0 4
      tests/misc/projects/Issue4803/compile-fail.hxml.stderr
  9. 1 3
      tests/misc/projects/Issue5946/compile-fail.hxml.stderr
  10. 0 2
      tests/misc/projects/Issue6065/compile-fail.hxml.stderr
  11. 1 2
      tests/misc/projects/Issue6714/compile-fail.hxml.stderr
  12. 1 2
      tests/misc/projects/Issue6790/compile-fail.hxml.stderr
  13. 1 2
      tests/misc/projects/Issue6796/compile-fail.hxml.stderr
  14. 1 3
      tests/misc/projects/Issue6810/compile-fail.hxml.stderr
  15. 1 2
      tests/misc/projects/Issue6826/compile-fail.hxml.stderr
  16. 1 2
      tests/misc/projects/Issue6878/compile1-fail.hxml.stderr
  17. 1 2
      tests/misc/projects/Issue7655/compile-fail.hxml.stderr
  18. 1 2
      tests/misc/projects/Issue8283/compile-fail.hxml.stderr
  19. 1 2
      tests/misc/projects/Issue8488/compile-fail.hxml.stderr
  20. 1 2
      tests/misc/projects/Issue8618/compile-fail.hxml.stderr
  21. 1 2
      tests/misc/projects/Issue8618/compile2-fail.hxml.stderr
  22. 1 2
      tests/misc/projects/Issue8618/compile3-fail.hxml.stderr
  23. 1 2
      tests/misc/projects/Issue8618/compile4-fail.hxml.stderr
  24. 1 2
      tests/misc/projects/Issue8704/compile-fail.hxml.stderr
  25. 1 2
      tests/misc/projects/Issue8787/compile1-fail.hxml.stderr
  26. 1 2
      tests/misc/projects/Issue8787/compile2-fail.hxml.stderr
  27. 1 2
      tests/misc/projects/Issue8819/compile-fail.hxml.stderr
  28. 1 2
      tests/misc/projects/Issue9556/compile-fail.hxml.stderr
  29. 1 1
      tests/unit/src/unit/issues/Issue3714.hx

+ 6 - 7
src/typing/calls.ml

@@ -144,9 +144,8 @@ let rec unify_call_args' ctx el args r callp inline force_inline =
 	let call_error err p =
 		raise (Error (Call_error err,p))
 	in
-	let arg_error ul name opt p =
-		let err = Stack (ul,Custom ("For " ^ (if opt then "optional " else "") ^ "function argument '" ^ name ^ "'")) in
-		call_error (Could_not_unify err) p
+	let arg_error ul p =
+		call_error (Could_not_unify ul) p
 	in
 	let mk_pos_infos t =
 		let infos = mk_infos ctx callp [] in
@@ -184,7 +183,7 @@ let rec unify_call_args' ctx el args r callp inline force_inline =
 		| _,[name,false,t] when (match follow t with TAbstract({a_path = ["haxe";"extern"],"Rest"},_) -> true | _ -> false) ->
 			begin match follow t with
 				| TAbstract({a_path=(["haxe";"extern"],"Rest")},[t]) ->
-					(try List.map (fun e -> type_against name t e,false) el with WithTypeError(ul,p) -> arg_error ul name false p)
+					(try List.map (fun e -> type_against name t e,false) el with WithTypeError(ul,p) -> arg_error ul p)
 				| _ ->
 					die "" __LOC__
 			end
@@ -206,7 +205,7 @@ let rec unify_call_args' ctx el args r callp inline force_inline =
 						ignore(type_expr ctx (e,p) WithType.value);
 						loop el []
 					end	else call_error Too_many_arguments p
-				| (s,ul,p) :: _ -> arg_error ul s true p
+				| (s,ul,p) :: _ -> arg_error ul p
 			end
 		| e :: el,(name,opt,t) :: args ->
 			begin try
@@ -219,8 +218,8 @@ let rec unify_call_args' ctx el args r callp inline force_inline =
 						(e_def,true) :: loop (e :: el) args
 					else
 						match List.rev !skipped with
-						| [] -> arg_error ul name opt p
-						| (s,ul,p) :: _ -> arg_error ul s true p
+						| [] -> arg_error ul p
+						| (s,ul,p) :: _ -> arg_error ul p
 			end
 	in
 	let el = try loop el args with exc -> ctx.in_call_args <- in_call_args; raise exc; in

+ 1 - 2
tests/misc/projects/Issue1310/compile1-fail.hxml.stderr

@@ -1,2 +1 @@
-Main1.hx:17: characters 13-18 : Array<Int> should be ToString.S
-Main1.hx:17: characters 13-18 : ... For function argument ''
+Main1.hx:17: characters 13-18 : Array<Int> should be ToString.S

+ 1 - 2
tests/misc/projects/Issue2148/compile1-fail.hxml.stderr

@@ -1,2 +1 @@
-Main1.hx:7: characters 22-25 : Unknown identifier : foo
-Main1.hx:7: characters 22-25 : ... For function argument 'i'
+Main1.hx:7: characters 22-25 : Unknown identifier : foo

+ 1 - 2
tests/misc/projects/Issue2232/compile1-fail.hxml.stderr

@@ -1,2 +1 @@
-Main1.hx:4: characters 7-8 : Float should be Int
-Main1.hx:4: characters 7-8 : ... For optional function argument 'x'
+Main1.hx:4: characters 7-8 : Float should be Int

+ 1 - 2
tests/misc/projects/Issue3781/compile-fail.hxml.stderr

@@ -1,3 +1,2 @@
 Main.hx:12: characters 12-13 : Constraint check failure for E1.T
-Main.hx:12: characters 12-13 : ... Main.T should be String
-Main.hx:12: characters 12-13 : ... For function argument 'v'
+Main.hx:12: characters 12-13 : ... Main.T should be String

+ 1 - 2
tests/misc/projects/Issue4540/compile-fail.hxml.stderr

@@ -1,2 +1 @@
-Main.hx:3: characters 57-58 : Int should be { test : String }
-Main.hx:3: characters 57-58 : ... For function argument 'a'
+Main.hx:3: characters 57-58 : Int should be { test : String }

+ 0 - 1
tests/misc/projects/Issue4775/compile1-fail.hxml.stderr

@@ -1,4 +1,3 @@
 Main1.hx:7: characters 15-26 : Constraint check failure for Contain.T
 Main1.hx:7: characters 15-26 : ... Main1 should be String
-Main1.hx:7: characters 15-26 : ... For function argument 't'
 Main1.hx:7: characters 3-27 : Could not determine type for parameter T

+ 0 - 4
tests/misc/projects/Issue4803/compile-fail.hxml.stderr

@@ -3,8 +3,4 @@ Main.hx:16: lines 16-19 : Overload resolution failed for () -> JQuery
 Main.hx:16: lines 16-19 : Too many arguments
 Main.hx:16: lines 16-19 : Overload resolution failed for (handler : (Event -> Void)) -> JQuery
 Main.hx:18: characters 8-17 : Object requires field y
-Main.hx:18: characters 8-17 : ... For function argument 'handler'
-Main.hx:16: lines 16-19 : Overload resolution failed for (?eventData : Null<Dynamic>, handler : (Event -> Void)) -> JQuery
-Main.hx:18: characters 8-17 : Object requires field y
-Main.hx:18: characters 8-17 : ... For optional function argument 'eventData'
 Main.hx:16: lines 16-19 : End of overload failure reasons

+ 1 - 3
tests/misc/projects/Issue5946/compile-fail.hxml.stderr

@@ -1,8 +1,6 @@
 Main.hx:4: characters 28-31 : Class<Two> should be Class<Unknown<0> : One>
 Main.hx:4: characters 28-31 : ... Constraint check failure for downcast.S
 Main.hx:4: characters 28-31 : ... Two should be One
-Main.hx:4: characters 28-31 : ... For function argument 'c'
 Main.hx:5: characters 29-33 : Class<ITwo> should be Class<Unknown<0> : IOne>
 Main.hx:5: characters 29-33 : ... Constraint check failure for downcast.S
-Main.hx:5: characters 29-33 : ... ITwo should be IOne
-Main.hx:5: characters 29-33 : ... For function argument 'c'
+Main.hx:5: characters 29-33 : ... ITwo should be IOne

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

@@ -4,7 +4,6 @@ Main.hx:8: characters 13-17 : Too many arguments
 Main.hx:8: characters 9-18 : Overload resolution failed for (t : f.T) -> Void
 Main.hx:8: characters 13-17 : Constraint check failure for f.T
 Main.hx:8: characters 13-17 : ... String should be Int
-Main.hx:8: characters 13-17 : ... For function argument 't'
 Main.hx:8: characters 9-18 : End of overload failure reasons
 Main.hx:9: characters 9-16 : Could not find a suitable overload, reasons follow
 Main.hx:9: characters 9-16 : Overload resolution failed for () -> Void
@@ -12,5 +11,4 @@ Main.hx:9: characters 13-15 : Too many arguments
 Main.hx:9: characters 9-16 : Overload resolution failed for (t : f.T) -> Void
 Main.hx:9: characters 13-15 : Constraint check failure for f.T
 Main.hx:9: characters 13-15 : ... { } should be Int
-Main.hx:9: characters 13-15 : ... For function argument 't'
 Main.hx:9: characters 9-16 : End of overload failure reasons

+ 1 - 2
tests/misc/projects/Issue6714/compile-fail.hxml.stderr

@@ -1,2 +1 @@
-Main.hx:10: characters 22-28 : String should be Bool
-Main.hx:10: characters 22-28 : ... For function argument 'a'
+Main.hx:10: characters 22-28 : String should be Bool

+ 1 - 2
tests/misc/projects/Issue6790/compile-fail.hxml.stderr

@@ -1,2 +1 @@
-Mismatch.hx:6: characters 19-26 : (e : Unknown<0>) -> String should be Null<js.lib.PromiseHandler<Dynamic, Int>>
-Mismatch.hx:6: characters 19-26 : ... For optional function argument 'onRejected'
+Mismatch.hx:6: characters 19-26 : (e : Unknown<0>) -> String should be Null<js.lib.PromiseHandler<Dynamic, Int>>

+ 1 - 2
tests/misc/projects/Issue6796/compile-fail.hxml.stderr

@@ -1,2 +1 @@
-Main.hx:3: characters 21-25 : Array access is not allowed on () -> Unknown<0>
-Main.hx:3: characters 21-25 : ... For function argument 'v'
+Main.hx:3: characters 21-25 : Array access is not allowed on () -> Unknown<0>

+ 1 - 3
tests/misc/projects/Issue6810/compile-fail.hxml.stderr

@@ -1,8 +1,6 @@
 Fail.hx:7: characters 8-12 : error: Void should be haxe.NotVoid
 Fail.hx:7: characters 8-12 : ... have: (...) -> Void
 Fail.hx:7: characters 8-12 : ... want: (...) -> haxe.NotVoid
-Fail.hx:7: characters 8-12 : ... For function argument 'f'
 Fail.hx:8: characters 8-16 : error: FakeVoid should be haxe.NotVoid
 Fail.hx:8: characters 8-16 : ... have: (...) -> FakeVoid
-Fail.hx:8: characters 8-16 : ... want: (...) -> haxe.NotVoid
-Fail.hx:8: characters 8-16 : ... For function argument 'f'
+Fail.hx:8: characters 8-16 : ... want: (...) -> haxe.NotVoid

+ 1 - 2
tests/misc/projects/Issue6826/compile-fail.hxml.stderr

@@ -1,2 +1 @@
-Main.hx:5: characters 20-21 : Expression cannot be empty
-Main.hx:5: characters 20-21 : ... For function argument 'v'
+Main.hx:5: characters 20-21 : Expression cannot be empty

+ 1 - 2
tests/misc/projects/Issue6878/compile1-fail.hxml.stderr

@@ -1,3 +1,2 @@
 Main1.hx:4: characters 8-10 : Constraint check failure for test.T
-Main1.hx:4: characters 8-10 : ... Int should be String
-Main1.hx:4: characters 8-10 : ... For function argument 't'
+Main1.hx:4: characters 8-10 : ... Int should be String

+ 1 - 2
tests/misc/projects/Issue7655/compile-fail.hxml.stderr

@@ -1,2 +1 @@
-Mismatch.hx:6: characters 19-26 : (e : Unknown<0>) -> String should be js.lib.PromiseHandler<Dynamic, Int>
-Mismatch.hx:6: characters 19-26 : ... For optional function argument 'onRejected'
+Mismatch.hx:6: characters 19-26 : (e : Unknown<0>) -> String should be js.lib.PromiseHandler<Dynamic, Int>

+ 1 - 2
tests/misc/projects/Issue8283/compile-fail.hxml.stderr

@@ -1,4 +1,3 @@
 Main.hx:9: characters 35-48 : Arrays of mixed types are only allowed if the type is forced to Array<Dynamic>
 Main.hx:9: characters 35-48 : Arrays of mixed types are only allowed if the type is forced to Array<Dynamic>
-Main.hx:9: characters 35-48 : String should be Int
-Main.hx:9: characters 35-48 : ... For optional function argument 'arr'
+Main.hx:9: characters 35-48 : String should be Int

+ 1 - 2
tests/misc/projects/Issue8488/compile-fail.hxml.stderr

@@ -1,2 +1 @@
-Main.hx:5: characters 45-48 : String should be Int
-Main.hx:5: characters 45-48 : ... For optional function argument 'a'
+Main.hx:5: characters 45-48 : String should be Int

+ 1 - 2
tests/misc/projects/Issue8618/compile-fail.hxml.stderr

@@ -1,2 +1 @@
-Main.hx:4: characters 9-36 : Method staticMethod cannot be used as a value
-Main.hx:4: characters 9-36 : ... For function argument 'v'
+Main.hx:4: characters 9-36 : Method staticMethod cannot be used as a value

+ 1 - 2
tests/misc/projects/Issue8618/compile2-fail.hxml.stderr

@@ -1,2 +1 @@
-Main2.hx:3: characters 9-45 : Method instanceMethod cannot be used as a value
-Main2.hx:3: characters 9-45 : ... For function argument 'v'
+Main2.hx:3: characters 9-45 : Method instanceMethod cannot be used as a value

+ 1 - 2
tests/misc/projects/Issue8618/compile3-fail.hxml.stderr

@@ -1,2 +1 @@
-Main3.hx:3: characters 9-42 : Method noClosureStaticMethod cannot be used as a value
-Main3.hx:3: characters 9-42 : ... For function argument 'v'
+Main3.hx:3: characters 9-42 : Method noClosureStaticMethod cannot be used as a value

+ 1 - 2
tests/misc/projects/Issue8618/compile4-fail.hxml.stderr

@@ -1,2 +1 @@
-Main4.hx:3: characters 9-51 : Method noClosureInstanceMethod cannot be used as a value
-Main4.hx:3: characters 9-51 : ... For function argument 'v'
+Main4.hx:3: characters 9-51 : Method noClosureInstanceMethod cannot be used as a value

+ 1 - 2
tests/misc/projects/Issue8704/compile-fail.hxml.stderr

@@ -1,2 +1 @@
-Main.hx:3: characters 14-16 : { } should be Under<Unknown<0>>
-Main.hx:3: characters 14-16 : ... For function argument 'v'
+Main.hx:3: characters 14-16 : { } should be Under<Unknown<0>>

+ 1 - 2
tests/misc/projects/Issue8787/compile1-fail.hxml.stderr

@@ -1,3 +1,2 @@
 Main1.hx:7: characters 7-9 : Constraint check failure for E.T
-Main1.hx:7: characters 7-9 : ... Int should be String
-Main1.hx:7: characters 7-9 : ... For function argument 't'
+Main1.hx:7: characters 7-9 : ... Int should be String

+ 1 - 2
tests/misc/projects/Issue8787/compile2-fail.hxml.stderr

@@ -1,3 +1,2 @@
 Main2.hx:7: characters 7-9 : Constraint check failure for C.T
-Main2.hx:7: characters 7-9 : ... Int should be String
-Main2.hx:7: characters 7-9 : ... For function argument 't'
+Main2.hx:7: characters 7-9 : ... Int should be String

+ 1 - 2
tests/misc/projects/Issue8819/compile-fail.hxml.stderr

@@ -1,2 +1 @@
-Main.hx:3: characters 17-20 : Abstract<Foo> should be Enum<Unknown<0>>
-Main.hx:3: characters 17-20 : ... For function argument 'e'
+Main.hx:3: characters 17-20 : Abstract<Foo> should be Enum<Unknown<0>>

+ 1 - 2
tests/misc/projects/Issue9556/compile-fail.hxml.stderr

@@ -1,3 +1,2 @@
 Main.hx:4: characters 5-10 : Constraint check failure for Main.T
-Main.hx:4: characters 5-10 : ... String should be Int
-Main.hx:4: characters 5-10 : ... For function argument 't'
+Main.hx:4: characters 5-10 : ... String should be Int

+ 1 - 1
tests/unit/src/unit/issues/Issue3714.hx

@@ -10,6 +10,6 @@ class Issue3714 extends Test {
 		eq(unit.HelperMacros.typeErrorText(A.f), "Cannot access private field f");
 		eq(unit.HelperMacros.typeErrorText(@:privateAccess A.f), null);
 		eq(unit.HelperMacros.typeErrorText(@:privateAccess A.f(A.a)), null);
-		eq(unit.HelperMacros.typeErrorText(@:privateAccess A.f(@:noPrivateAccess A.a)), "Cannot access private field a\nFor function argument 'a'");
+		eq(unit.HelperMacros.typeErrorText(@:privateAccess A.f(@:noPrivateAccess A.a)), "Cannot access private field a");
 	}
 }