summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level-2/funcs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'starts/meaning-vm/level-2/funcs.cpp')
-rw-r--r--starts/meaning-vm/level-2/funcs.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/starts/meaning-vm/level-2/funcs.cpp b/starts/meaning-vm/level-2/funcs.cpp
index a8835f4..11b3184 100644
--- a/starts/meaning-vm/level-2/funcs.cpp
+++ b/starts/meaning-vm/level-2/funcs.cpp
@@ -46,13 +46,18 @@ ref dohabit(ref habit, std::initializer_list<ref> args)
if (posarg.linked(next-positional-argument)) {
throw std::invalid_argument("wrong number of arguments to habit");
}
- ref ret = habit.fun<ref>()(ref::context());
+ habit.fun<ref>()(ref::context());
posarg = habit;
while (posarg.linked(next-positional-argument)) {
posarg = posarg[next-positional-argument];
ref::context().unlink(posarg[argument]);
}
- return ret;
+ if (ref::context().linked(result)) {
+ ref ret = ref::context().get(result);
+ ref::context().unlink(result, ret);
+ return ret;
+ }
+ return nothing;
}
}