bugfix: initial value of parameter must be registered to the top

dynamic env
This commit is contained in:
Yuichi Nishiwaki 2017-04-02 01:13:03 +09:00
parent eaea31ee19
commit 7b3972e832
1 changed files with 11 additions and 2 deletions

View File

@ -40,10 +40,19 @@ var_call(pic_state *pic)
pic_value pic_value
pic_make_var(pic_state *pic, pic_value init, pic_value conv) pic_make_var(pic_state *pic, pic_value init, pic_value conv)
{ {
pic_value var; pic_value var, env = pic->dyn_env;
var = pic_lambda(pic, var_call, 1, conv); var = pic_lambda(pic, var_call, 1, conv);
pic_call(pic, var, 1, init); while (1) {
if (pic_nil_p(pic, pic_cdr(pic, env))) { /* top dyn env */
if (! pic_false_p(pic, conv)) {
init = pic_call(pic, conv, 1, init);
}
pic_weak_set(pic, pic_car(pic, env), var, init);
break;
}
env = pic_cdr(pic, env);
}
return var; return var;
} }