lua-users home
lua-l archive

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


Roberto Ierusalimschy wrote:
[...]

So the debug info is corrupted...
Yep, thought so too..

Can you add this piece of code in
luaI_registerlocalvar (lparser.c:144, just before the return) and
see what it prints?

  { int i; for (i=0; i<f->nlocvars; i++)
    printf("%d: %s  ", f->locvars[i].varname; printf("\n"); }


Slightly modified:

  printf("luaI_registerlocalvar() %s:%d; ", __FILE__, __LINE__ );
  { int i; for (i=0; i<=fs->nlocvars; i++)
    printf("%d: %s  ", i, getstr(f->locvars[i].varname)); printf("\r\n"); }


Got this:
> do
        local test = {}
        test.__index = test

        function test:foo()
                return self[1]
        end

        function test:func( idx )

              local a, b, c = 1, 2, { foo = idx }
                if idx.foo then return false end
                return self:foo() + idx
        end

        function new_test()
                return setmetatable( { 1, 2, 3, 4, 5 }, test )
        end
end
luaI_registerlocalvar() lparser.c:148; 0: test
luaI_registerlocalvar() lparser.c:148; 0: self
luaI_registerlocalvar() lparser.c:148; 0: self
luaI_registerlocalvar() lparser.c:148; 0: self  1: idx
luaI_registerlocalvar() lparser.c:148; 0: self  1: idx  2: a
luaI_registerlocalvar() lparser.c:148; 0: self  1: idx  2: a  3: b
luaI_registerlocalvar() lparser.c:148; 0: self  1: idx  2: a  3: b  4: c
> t=new_test(); return t:func(3)
luaF_getlocalname() lfunc.c:130; 0: self  1: self  2: self  3: self  4: self
R2RMon: stdin:11: attempt to index local `self' (a number value)
stack traceback:
        stdin:11: in function <stdin:9>
        (tail call): ?
        [C]: ?
>

I leave any conclusions too you..

//Andreas