1
1
mirror of https://github.com/kanaka/mal.git synced 2024-08-17 09:40:21 +03:00

d: prevent defmacro from mutating functions

This commit is contained in:
Nicolas Boulenguez 2021-08-30 23:38:46 +02:00 committed by Joel Martin
parent e3c376ebd5
commit 13a84ba0aa
3 changed files with 3 additions and 0 deletions

View File

@ -165,6 +165,7 @@ MalType EVAL(MalType ast, Env env)
case "defmacro!":
auto a1 = verify_cast!MalSymbol(aste[1]);
auto mac = verify_cast!MalFunc(EVAL(aste[2], env));
mac = new MalFunc(mac.arg_names, mac.func_body, mac.def_env);
mac.is_macro = true;
return env.set(a1, mac);

View File

@ -165,6 +165,7 @@ MalType EVAL(MalType ast, Env env)
case "defmacro!":
auto a1 = verify_cast!MalSymbol(aste[1]);
auto mac = verify_cast!MalFunc(EVAL(aste[2], env));
mac = new MalFunc(mac.arg_names, mac.func_body, mac.def_env);
mac.is_macro = true;
return env.set(a1, mac);

View File

@ -166,6 +166,7 @@ MalType EVAL(MalType ast, Env env)
case "defmacro!":
auto a1 = verify_cast!MalSymbol(aste[1]);
auto mac = verify_cast!MalFunc(EVAL(aste[2], env));
mac = new MalFunc(mac.arg_names, mac.func_body, mac.def_env);
mac.is_macro = true;
return env.set(a1, mac);