@@ -91,7 +91,7 @@ def check_type_is_explicit(lineno: int, id_: str, type_):
9191 errmsg .syntax_error_undeclared_type (lineno , id_ )
9292
9393
94- def check_call_arguments (lineno : int , id_ : str , args ):
94+ def check_call_arguments (lineno : int , id_ : str , args , filename : str ):
9595 """Check arguments against function signature.
9696
9797 Checks every argument in a function call against a function.
@@ -109,14 +109,14 @@ def check_call_arguments(lineno: int, id_: str, args):
109109 param_names = {x .name for x in entry .ref .params }
110110 for arg in args :
111111 if arg .name is not None and arg .name not in param_names :
112- errmsg .error (lineno , f"Unexpected argument '{ arg .name } '" , fname = entry . filename )
112+ errmsg .error (lineno , f"Unexpected argument '{ arg .name } '" , fname = filename )
113113 return False
114114
115115 last_arg_name = None
116116 for arg , param in zip (args , entry .ref .params ):
117117 if last_arg_name is not None and arg .name is None :
118118 errmsg .error (
119- lineno , f"Positional argument cannot go after keyword argument '{ last_arg_name } '" , fname = entry . filename
119+ lineno , f"Positional argument cannot go after keyword argument '{ last_arg_name } '" , fname = filename
120120 )
121121 return False
122122
@@ -139,15 +139,13 @@ def check_call_arguments(lineno: int, id_: str, args):
139139
140140 for arg in args :
141141 if arg .name is None :
142- errmsg .error (lineno , f"Too many arguments for Function '{ id_ } '" , fname = entry . filename )
142+ errmsg .error (lineno , f"Too many arguments for Function '{ id_ } '" , fname = filename )
143143 return False
144144
145145 if len (named_args ) != len (entry .ref .params ):
146146 c = "s" if len (entry .ref .params ) != 1 else ""
147147 errmsg .error (
148- lineno ,
149- f"Function '{ id_ } ' takes { len (entry .ref .params )} parameter{ c } , not { len (args )} " ,
150- fname = entry .filename ,
148+ lineno , f"Function '{ id_ } ' takes { len (entry .ref .params )} parameter{ c } , not { len (args )} " , fname = filename
151149 )
152150 return False
153151
@@ -195,8 +193,8 @@ def check_pending_calls():
195193 result = True
196194
197195 # Check for functions defined after calls (parameters, etc)
198- for id_ , params , lineno in global_ .FUNCTION_CALLS :
199- result = result and check_call_arguments (lineno , id_ , params )
196+ for call in global_ .FUNCTION_CALLS :
197+ result = result and check_call_arguments (call . lineno , call . entry . original_name , call . args , call . filename )
200198
201199 return result
202200
0 commit comments