lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


The bytecode hack that works:

replace the case ':' clause in suffixedexp in lparser.c with:

case ':': {  /* `:' NAME funcargs */
        expdesc key;
        int flag=0;
        luaX_next(ls);
        if (ls->t.token=='[') {
           luaK_exp2anyregup(fs, v);
           yindex(ls, &key);
           if (key.k==VNONRELOC){flag=1;}

        }
        else
            checkname(ls, &key);
        luaK_self(fs, v, &key);
        if (flag) ls->fs->freereg++;
        funcargs(ls, v, line);
        break;
      }

This will detect and correct the pathological cases of bytecode generation.

Special thanks to Luiz for the original patch and to Roberto for pointing me in the right direction.

Is some kind of error checking in order for the line if (flag) ls->fs->freereg++;? I don't see the need based on the source code of yindex, etc., but I could be overlooking something.


If anyone finds a case in which this fails, please let me know, the detection clause may need to be more complex.


-- Mike