dearblue · GitHub

  • Good case : Calling super from a 15-level lambda

    % bin/mruby -vce 'def m(a, b, c); ->{->{->{->{->{->{->{->{->{->{->{->{->{->{->{ super }}}}}}}}}}}}}}}; end'
    ...SNIP...
    irep 0x220d1d869550 nregs=6 nlocals=2 pools=0 syms=0 reps=0 ilen=13
    file: -e
        1 000 ENTER         0:0:0:0:0:0:0 (0x0)
        1 004 ARGARY        R3      3:0:0:0 (15)    ### see "(15)" (good) ###
        1 008 SUPER         R2      n=*
        1 011 RETURN        R2
    Syntax OK
  • Wrong case : Calling super from a 17-level lambda

    % bin/mruby -vce 'def m(a, b, c); ->{->{->{->{->{->{->{->{->{->{->{->{->{->{->{->{->{ super }}}}}}}}}}}}}}}}}; end'
    ...SNIP...
    irep 0x32923e8695f0 nregs=6 nlocals=2 pools=0 syms=0 reps=0 ilen=13
    file: -e
        1 000 ENTER         0:0:0:0:0:0:0 (0x0)
        1 004 ARGARY        R3      3:0:0:0 (1)     ### see "(1)" (overflowed) ###
        1 008 SUPER         R2      n=*
        1 011 RETURN        R2
    Syntax OK

😸 The strongest solution I have come up with is to call codegen_error(s, "too complex expression") if the number exceeds 15.

There may be a better solution, so I'm just reporting it for now.

Read the original on github.com ↗