Browse Source

fix positions of optional argument null-expressions (closes #5652)

Simon Krajewski 9 years ago
parent
commit
2345a24a12

+ 2 - 2
src/typing/typeload.ml

@@ -2523,14 +2523,14 @@ module ClassInitializer = struct
 		(* TODO is_lib: avoid forcing the return type to be typed *)
 		let ret = if fctx.field_kind = FKConstructor then ctx.t.tvoid else type_opt (ctx,cctx) p fd.f_type in
 		let rec loop args = match args with
-			| ((name,_),opt,m,t,ct) :: args ->
+			| ((name,p),opt,m,t,ct) :: args ->
 				(* TODO is_lib: avoid forcing the field to be typed *)
 				let t, ct = type_function_arg ctx (type_opt (ctx,cctx) p t) ct opt p in
 				delay ctx PTypeField (fun() -> match follow t with
 					| TAbstract({a_path = ["haxe";"extern"],"Rest"},_) ->
 						if not c.cl_extern then error "Rest argument are only supported for extern methods" p;
 						if opt then error "Rest argument cannot be optional" p;
-						if ct <> None then error "Rest argument cannot have default value" p;
+						begin match ct with None -> () | Some (_,p) -> error "Rest argument cannot have default value" p end;
 						if args <> [] then error "Rest should only be used for the last function argument" p;
 					| _ ->
 						()

+ 1 - 1
tests/misc/projects/Issue3238/default-value-fail.hxml.stderr

@@ -1 +1 @@
-DefaultValue.hx:2: characters 4-55 : Rest argument cannot have default value
+DefaultValue.hx:2: characters 44-48 : Rest argument cannot have default value

+ 1 - 1
tests/misc/projects/Issue3238/non-extern-fail.hxml.stderr

@@ -1 +1 @@
-NonExtern.hx:2: characters 11-57 : Rest argument are only supported for extern methods
+NonExtern.hx:2: characters 22-23 : Rest argument are only supported for extern methods

+ 1 - 1
tests/misc/projects/Issue3238/not-last-fail.hxml.stderr

@@ -1 +1 @@
-NotLast.hx:2: characters 4-58 : Rest should only be used for the last function argument
+NotLast.hx:2: characters 15-16 : Rest should only be used for the last function argument

+ 1 - 1
tests/misc/projects/Issue3238/optional-fail.hxml.stderr

@@ -1 +1 @@
-Optional.hx:2: characters 4-49 : Rest argument cannot be optional
+Optional.hx:2: characters 16-17 : Rest argument cannot be optional