codegen.c: ainfo may be negative.

When argument information is not available. So it should not happen for
`yield` (error). In contrast, the error from `super` should be handled
in run time (ignored).
This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-03-29 22:43:43 +09:00
parent 87f113e19d
commit 4428ce6050
+7 -2
View File
@@ -2321,7 +2321,9 @@ codegen(codegen_scope *s, node *tree, int val)
s2 = s2->prev;
if (!s2) break;
}
if (s2) ainfo = s2->ainfo;
if (s2 && s2->ainfo > 0) {
ainfo = s2->ainfo;
}
genop_2S(s, OP_ARGARY, cursp(), (ainfo<<4)|(lv & 0xf));
push(); push(); pop(); /* ARGARY pushes two values */
if (tree && tree->cdr) {
@@ -2361,7 +2363,10 @@ codegen(codegen_scope *s, node *tree, int val)
s2 = s2->prev;
if (!s2) break;
}
if (s2) ainfo = s2->ainfo;
if (s2) {
ainfo = s2->ainfo;
if (ainfo < 0) codegen_error(s, "invalid yield");
}
push();
if (tree) {
n = gen_values(s, tree, VAL, 0);