Commit 55b2e45a authored by dearblue's avatar dearblue

Fixing keyword arguments with `super`

fix #5627
parent d34e1cb8
...@@ -2854,8 +2854,8 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -2854,8 +2854,8 @@ codegen(codegen_scope *s, node *tree, int val)
if (s2 && (s2->ainfo & 0x1) && tree->cdr->car) { if (s2 && (s2->ainfo & 0x1) && tree->cdr->car) {
nk = gen_hash(s, tree->cdr->car->cdr, VAL, 14); nk = gen_hash(s, tree->cdr->car->cdr, VAL, 14);
if (nk < 0) {st++; nk = 15;} if (nk < 0) {st++; nk = 15;}
else st += nk; else st += nk*2;
n |= 15<<4; n |= nk<<4;
} }
/* block arguments */ /* block arguments */
if (tree->cdr->cdr) { if (tree->cdr->cdr) {
......
...@@ -1729,6 +1729,16 @@ RETRY_TRY_BLOCK: ...@@ -1729,6 +1729,16 @@ RETRY_TRY_BLOCK:
} }
mrb_assert(bidx < irep->nregs); mrb_assert(bidx < irep->nregs);
uint8_t nk = (b >> 4) & 0x0f;
if (nk > 0 && nk < CALL_MAXARGS) { /* pack keyword arguments */
uint8_t n = b & 0x0f;
mrb_int kidx = a+(n==15?1:n)+1;
mrb_value kdict = hash_new_from_values(mrb, nk, regs+kidx);
regs[kidx] = kdict;
nk = 15;
b = n | (nk<<4);
}
if (mid == 0 || !target_class) { if (mid == 0 || !target_class) {
mrb_value exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method"); mrb_value exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
mrb_exc_set(mrb, exc); mrb_exc_set(mrb, exc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment