[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Error reporting: the chunk name
- From: "John Hind" <john.hind@...>
- Date: Fri, 20 Nov 2009 09:45:49 -0000
Thanks - I did actually read this but did not twig that it would have this
effect - the @ prefix is documented as making this a filename (actually due
to the font used in the Reference Manual it is almost impossible to see what
the symbol is!).
Using this seems like a fudge - some third party debugging tool might
reasonably then try to use your name as a filename and fall over.
I think this is a case were the documentation is good, the implemented
behaviour is at fault. There are three distinct cases (filename, source
code, user-supplied name) and there should be an explicit marker for each.
[mailto:email@example.com] On Behalf Of Matthew Wild
Sent: 19 November 2009 22:03
To: Lua list
Subject: Re: Error reporting: the chunk name
2009/11/19 John Hind <firstname.lastname@example.org>:
> I have been trying to improve the error reporting in some of my code and
> came across another slightly rough area of Lua. I have been using
> luaL_loadstring to load text from a Windows EXE named resource. Errors get
> reported something like:
> [string: "x = x + 1"]:1: attempt to perform arithmetic on global 'x' (a
> I tried using luaL_loadbuffer, specifying the name of the resource as the
> last parameter (chunk name). But it still insists on adding the
> inappropriate 'string' prefix and enclosing my supplied name in quotes:
> [string: "myres"]:1: attempt to perform arithmetic on global 'x' (a nil
> Even using lua_load with a custom lua_Reader function, the unwanted
> prefixing is still done, so it seems to be impossible to get "under" this
> unwanted processing with the published API.
Try prefixing the chunk name you pass with '@', e.g. '@myres'. Worked
that one out the hard way :)