summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-03-29 22:43:43 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-03-31 10:48:17 +0900
commit4428ce6050efb89f5777f9ec4f07eb913591b7a3 (patch)
tree7e7ddda365c66b8abb13ac2c83a1507d66907b6e
parent87f113e19d6932a82392c63539b107ae35b1049e (diff)
downloadmruby-4428ce6050efb89f5777f9ec4f07eb913591b7a3.tar.gz
mruby-4428ce6050efb89f5777f9ec4f07eb913591b7a3.zip
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).
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index 857496f00..a5d9a4b8e 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -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);