Browse Source

[nullsafety] use callee pos for args error reporting if own pos is null_pos (fixes #7821)

Alexander Kuzmenko 6 years ago
parent
commit
f56fc0f1be
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/typing/nullSafety.ml

+ 3 - 2
src/typing/nullSafety.ml

@@ -1256,8 +1256,9 @@ class expr_checker mode immediate_execution report =
 				| (arg :: args, (arg_name, optional, t) :: types) ->
 					if not optional && not (self#can_pass_expr arg t arg.epos) then begin
 						let fn_str = match symbol_name callee with "" -> "" | name -> " of function \"" ^ name ^ "\""
-						and arg_str = if arg_name = "" then "" else " \"" ^ arg_name ^ "\"" in
-						self#error ("Cannot pass nullable value to not-nullable argument" ^ arg_str ^ fn_str ^ ".") arg.epos
+						and arg_str = if arg_name = "" then "" else " \"" ^ arg_name ^ "\""
+						and pos = if arg.epos = null_pos then callee.epos else arg.epos in
+						self#error ("Cannot pass nullable value to not-nullable argument" ^ arg_str ^ fn_str ^ ".") pos
 					end;
 					(match arg.eexpr with
 						| TFunction fn ->