Use more cloneObject()

This commit is contained in:
Sage Vaillancourt 2020-11-03 00:07:08 -05:00
parent e0153528a1
commit 8c71fd2242
1 changed files with 3 additions and 3 deletions

View File

@ -340,14 +340,14 @@ Object filter(Object obj1, Object obj2, struct Environment *env)
Object append(Object list, Object newElement, struct Environment *env) Object append(Object list, Object newElement, struct Environment *env)
{ {
Object newList = cloneObject(list); Object newList = cloneObject(list);
nf_addToList(&newList, newElement); nf_addToList(&newList, cloneObject(newElement));
return newList; return newList;
} }
Object prepend(Object list, Object newElement, struct Environment *env) Object prepend(Object list, Object newElement, struct Environment *env)
{ {
Object newList = listObject(); Object newList = listObject();
nf_addToList(&newList, newElement); nf_addToList(&newList, cloneObject(newElement));
appendList(&newList, &list); appendList(&newList, &list);
return newList; return newList;
} }
@ -364,7 +364,7 @@ Object rest(Object list, Object ignore, struct Environment *env)
FOR_POINTER_IN_LIST(l) { FOR_POINTER_IN_LIST(l) {
if(POINTER == l->list) if(POINTER == l->list)
continue; continue;
nf_addToList(&ret, *POINTER); nf_addToList(&ret, cloneObject(*POINTER));
} }
return ret; return ret;
} }