@@ -143,7 +143,6 @@ static CB_INLINE int do_call(unsigned short num_args, struct cb_frame *frame,
143143 struct cb_value func_val ;
144144 struct cb_function * func ;
145145 int failed ;
146- int num_opt_params ;
147146
148147 func_val = * (* sp - num_args - 1 );
149148
@@ -156,10 +155,7 @@ static CB_INLINE int do_call(unsigned short num_args, struct cb_frame *frame,
156155 }
157156
158157 func = func_val .val .as_function ;
159- num_opt_params = func -> type == CB_FUNCTION_USER
160- ? func -> value .as_user .num_opt_params
161- : 0 ;
162- if (func -> arity - num_opt_params > num_args ) {
158+ if (func -> arity > num_args ) {
163159 cb_str s = cb_agent_get_string (func -> name );
164160 struct cb_value err ;
165161 cb_value_from_fmt (& err , "Too few arguments to function '%s'\n" ,
@@ -182,9 +178,9 @@ static CB_INLINE int do_call(unsigned short num_args, struct cb_frame *frame,
182178 next_frame .num_args = num_args ;
183179 next_frame .module_id = cb_modspec_id (code -> modspec );
184180 next_frame .code = code ;
185- next_frame .bp = * sp - * stack - num_args - 1 ;
181+ next_frame .bp = old_sp - num_args - 1 ;
186182
187- ensure_stack (code -> stack_size , * sp - * stack );
183+ ensure_stack (code -> stack_size , old_sp );
188184 failed = cb_eval (& next_frame );
189185 }
190186
0 commit comments