do not suppose in eval that list first element is function

This commit is contained in:
VaclavT 2021-05-04 19:59:49 +02:00
parent 5ca8f64853
commit 358414d7d3
1 changed files with 12 additions and 12 deletions

6
ml.cpp
View File

@ -729,11 +729,11 @@ MlValue MlValue::eval(MlEnvironment &env) {
args = std::vector<MlValue>(list.begin() + 1, list.end()); args = std::vector<MlValue>(list.begin() + 1, list.end());
function = list[0].eval(env);
if (function.type == BUILTIN || function.type == LAMBDA) {
// Only evaluate our arguments if it's not builtin! // Only evaluate our arguments if it's not builtin!
// Builtin functions can be special forms, so we // Builtin functions can be special forms, so we
// leave them to evaluate their arguments. // leave them to evaluate their arguments.
function = list[0].eval(env);
if (!function.is_builtin()) if (!function.is_builtin())
for (size_t i = 0; i < args.size(); i++) for (size_t i = 0; i < args.size(); i++)
args[i] = args[i].eval(env); args[i] = args[i].eval(env);
@ -741,8 +741,8 @@ MlValue MlValue::eval(MlEnvironment &env) {
MlPerfMon::instance().add_method_call(function.type == LAMBDA ? "lambda" : function.str); MlPerfMon::instance().add_method_call(function.type == LAMBDA ? "lambda" : function.str);
res = function.apply(args, env); res = function.apply(args, env);
MlPerfMon::instance().end_method_call(); MlPerfMon::instance().end_method_call();
return res; return res;
}
default: default:
return *this; return *this;