Skip to content
This repository has been archived by the owner on Jan 16, 2021. It is now read-only.

Commit

Permalink
3409
Browse files Browse the repository at this point in the history
  • Loading branch information
akkartik committed Mar 5, 2014
1 parent b20ecdb commit ff42771
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
10 changes: 4 additions & 6 deletions 021eval.cc
Expand Up @@ -382,13 +382,11 @@ void bind_aliases(cell* param, bool is_params_quoted, cell* arg, cell* scope, ce
}
else if (is_cons(alias)) {
trace("bind") << "destructured alias (as-param) " << alias << '\n';
if (!is_cons(arg)) {
bind_params(alias, true, nil, scope, new_scope, is_macro);
}
else {
TEMP(val, eval_arg(arg, scope));
bind_params(alias, true, val, scope, new_scope, is_macro);
if (!eval_done) {
update(val, eval_arg(arg, scope));
eval_done = true;
}
bind_params(alias, true, is_cons(val) ? val : nil, scope, new_scope, is_macro);
}
else {
RAISE << "unknown alias in " << param << '\n';
Expand Down
8 changes: 8 additions & 0 deletions 021eval.test.cc
Expand Up @@ -645,6 +645,14 @@ void test_eval_binds_as_params() {
CHECK_TRACE_CONTENTS("bind", "a: (1 2)b: 1c: 2");
}

void test_eval_binds_as_params2() {
TEMP(val, read("(1 2)"));
new_dynamic_scope("x", val);
run("((fn ((a | (b c))) 3) x)");
CHECK_TRACE_CONTENTS("bind", "a: (1 2)b: 1c: 2");
end_dynamic_scope("x");
}

void test_eval_binds_as_params_with_keyword_args() {
run("((fn (a | (b c)) 3) 1 :b 2)");
CHECK_TRACE_CONTENTS("bind", "a: (1 :b 2)b: 2c: 1");
Expand Down
1 change: 0 additions & 1 deletion 045check.test
Expand Up @@ -204,7 +204,6 @@
(test "match? - atom positive"
:valueof (match? 3 3)
:should be_true)
exit 0

(test "match? - atom negative"
:valueof (match? 3 4)
Expand Down
1 change: 1 addition & 0 deletions 050list2.test
Expand Up @@ -172,6 +172,7 @@
(test "pos works"
:valueof (pos 2 '(1 2 3))
:should be_true)
exit 0

(test "pos works - 2"
:valueof (pos 4 '(1 2 3))
Expand Down
6 changes: 5 additions & 1 deletion 050list2.wart
Expand Up @@ -27,7 +27,11 @@ def (pos x (seq | (head ... tail)) n)
if seq
if (head = x)
n
(pos x tail n+1)
trace "bind"
(pos x tail n+1)

prn (pos 2 '(1 2 3))
exit 0

def (rpos x seq n)
aif (pos x rev.seq n)
Expand Down

0 comments on commit ff42771

Please sign in to comment.