Skip to content

Commit

Permalink
objc: prevent defmacro! from mutating its argument
Browse files Browse the repository at this point in the history
  • Loading branch information
asarhaddon authored and kanaka committed Aug 27, 2024
1 parent 55c28a7 commit 99f8b02
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion impls/objc/step8_macros.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ BOOL starts_with(NSObject *ast, NSString *sym) {
} else if ([(NSString *)a0 isEqualTo:@"quasiquote"]) {
ast = quasiquote(alst[1]); // TCO
} else if ([a0sym isEqualTo:@"defmacro!"]) {
MalFunc * f = (MalFunc *)EVAL(alst[2], env);
MalFunc * f = [(MalFunc *)EVAL(alst[2], env) copy];
f.isMacro = true;
return [env set:alst[1] val:f];
} else if ([a0sym isEqualTo:@"do"]) {
Expand Down
2 changes: 1 addition & 1 deletion impls/objc/step9_try.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ BOOL starts_with(NSObject *ast, NSString *sym) {
} else if ([(NSString *)a0 isEqualTo:@"quasiquote"]) {
ast = quasiquote(alst[1]); // TCO
} else if ([a0sym isEqualTo:@"defmacro!"]) {
MalFunc * f = (MalFunc *)EVAL(alst[2], env);
MalFunc * f = [(MalFunc *)EVAL(alst[2], env) copy];
f.isMacro = true;
return [env set:alst[1] val:f];
} else if ([a0sym isEqualTo:@"try*"]) {
Expand Down
2 changes: 1 addition & 1 deletion impls/objc/stepA_mal.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ BOOL starts_with(NSObject *ast, NSString *sym) {
} else if ([(NSString *)a0 isEqualTo:@"quasiquote"]) {
ast = quasiquote(alst[1]); // TCO
} else if ([a0sym isEqualTo:@"defmacro!"]) {
MalFunc * f = (MalFunc *)EVAL(alst[2], env);
MalFunc * f = [(MalFunc *)EVAL(alst[2], env) copy];
f.isMacro = true;
return [env set:alst[1] val:f];
} else if ([a0sym isEqualTo:@"try*"]) {
Expand Down

0 comments on commit 99f8b02

Please sign in to comment.