aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-05-21 08:27:47 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-05-21 13:19:48 +0200
commit567c3d8dc28e99278b5db0edf53e93783e835fe9 (patch)
tree4a1aaffb2b4e847d92e754e5339d90804221a904
parent4d15d9cc6b7035fe5d5bfa390c2d6e6c24b51914 (diff)
downloadell-567c3d8dc28e99278b5db0edf53e93783e835fe9.tar.gz
ell-567c3d8dc28e99278b5db0edf53e93783e835fe9.tar.xz
ell-567c3d8dc28e99278b5db0edf53e93783e835fe9.zip
Fix missing argument values
-rwxr-xr-xell.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/ell.c b/ell.c
index d925523..6becbe9 100755
--- a/ell.c
+++ b/ell.c
@@ -756,11 +756,12 @@ execute_args (struct context *ctx, struct item *args, struct item **res) {
struct item *evaluated = NULL;
if (!execute_statement (ctx, args, &evaluated))
return false;
- if (evaluated) {
- item_free_list (evaluated->next);
- evaluated->next = NULL;
- res = &(*res = evaluated)->next;
- }
+ // Arguments should not evaporate, default to a nil value
+ if (!evaluated && !check (ctx, (evaluated = new_list (NULL))))
+ return false;
+ item_free_list (evaluated->next);
+ evaluated->next = NULL;
+ res = &(*res = evaluated)->next;
}
return true;
}
@@ -806,8 +807,8 @@ execute_statement
if (statement->type == ITEM_STRING)
return check (ctx, (*result = new_clone (statement)));
- // XXX: should this ever happen and what are the consequences?
- // Shouldn't we rather clone the empty list?
+ // Executing a nil value results in no value. It's not very different from
+ // calling a block that returns no value--it's for our callers to resolve.
struct item *body;
if (!(body = statement->head))
return true;