@@ -214,7 +214,8 @@ namespace runtime {
214214 for (const auto &argument: functionApplication.arguments ) {
215215 argumentThunks.push_back (std::make_shared<Thunk>(argument.get (), environment));
216216 }
217- return applyFunctionApplication (functionValue, argumentThunks, environment, functionApplication.location );
217+ frontend::Location newLocation = functionApplication.location ;
218+ return applyFunctionApplication (functionValue, argumentThunks, environment, newLocation);
218219 }
219220
220221 Value evalExpression (const frontend::Expression &expression, std::shared_ptr<Environment> environment) {
@@ -241,24 +242,15 @@ namespace runtime {
241242 return thunk;
242243 }
243244
244- std::vector<Value> forceArguments (const std::vector<std::shared_ptr<Thunk> > &arguments) {
245- std::vector<Value> values;
246- values.reserve (arguments.size ());
247- for (const auto &argument: arguments) {
248- values.push_back (argument->force ());
249- }
250- return values;
251- }
252-
253- Value applyFunctionApplication (Value functionName, const std::vector<std::shared_ptr<Thunk> > &arguments,
245+ Value applyFunctionApplication (const Value &functionName, const std::vector<std::shared_ptr<Thunk> > &arguments,
254246 const std::shared_ptr<Environment> &callSiteEnvironment,
255247 const std::optional<frontend::Location> &callLocation) {
256248 // Local mutable copy of the args, for inserting evaluated values as Thunks when needed.
257249 std::vector<std::shared_ptr<Thunk> > workArguments = arguments;
258250 // Frame Stack: Functions to which we are currently applying Arguments.
259251 // Start with the initial Function.
260252 std::vector<Value> frames;
261- frames.push_back (std::move ( functionName) );
253+ frames.push_back (functionName);
262254 size_t index = 0 ; // Index of next Thunk to consume from work_args
263255 while (true ) {
264256 // If there are no frames left, that's unexpected (shouldn't happen), bail.
@@ -316,17 +308,15 @@ namespace runtime {
316308 for (size_t i = 0 ; i < arity; ++i) {
317309 slice.push_back (workArguments[index + i]);
318310 }
319- // // ReSharper disable once CppTooWideScopeInitStatement
320- // std::vector<Value> releasedValues = forceArguments(slice);
321- // // Type-Check the function-arguments.
322- // if (!signature.matchesArgumentTypes(releasedValues)) {
323- // optionsValue.logger.error(callLocation,
324- // "runtime error: wrong arguments provided to native-function ",
325- // nativeFunction.getName(),
326- // "\n", nativeFunction.getName(), " signature: ", signature.toString());
327- // // TODO: Also print exactly which argument caused the error.
328- // // Print the signature got, with the incorrect argument color differently.
329- // }
311+ // Type-Check the function-arguments.
312+ if (!signature.matchesArgumentTypes (slice)) {
313+ optionsValue.logger .error (callLocation,
314+ " runtime error: wrong arguments provided to native-function " ,
315+ nativeFunction.getName (),
316+ " \n " , nativeFunction.getName (), " signature: " , signature.toString ());
317+ // TODO: Also print exactly which argument caused the error.
318+ // Print the signature got, with the incorrect argument color differently.
319+ }
330320 auto [resultantValue_, resultOptions] = nativeFunction.getImplementation ()(
331321 slice, callSiteEnvironment);
332322 if (!signature.matchesReturnType (resultantValue_)) {
0 commit comments