edubart / nelua-lang

Minimal, efficient, statically-typed and meta-programmable systems programming language heavily inspired by Lua, which compiles to C and native code.
https://nelua.io
MIT License
1.99k stars 64 forks source link

Broken preprocessor after 9faaa66e #247

Closed stefanos82 closed 8 months ago

stefanos82 commented 8 months ago

Up to 9faaa66e8b94e783c46898552c3eb873c26858ff preprocessor works as expected with code starting with ##[==[ and execute your Lua code in it.

Now, with the latest changes I get the following error:

findccinfo.nelua:1:1: error: error while preprocessing block: /home/stefanos/code/nelua/various/findccinfo.nelua:@ppcode:25: bad argument #1 to 'gsub' (string expected, got nil)
##[==[
^~~~~~

stack traceback:
        [C]: in function 'string.gsub'
        /home/stefanos/code/nelua/various/findccinfo.nelua:@ppcode:25: in function </home/stefanos/code/nelua/various/findccinfo.nelua:@ppcode:2>
        [C]: in function 'xpcall'
        /usr/local/lib/nelua/lualib/nelua/utils/except.lua:154: in function 'nelua.utils.except.trycall'
        /usr/local/lib/nelua/lualib/nelua/analyzer.lua:1857: in field '?'
        /usr/local/lib/nelua/lualib/nelua/analyzercontext.lua:112: in function 'nelua.analyzercontext.traverse_node'
        /usr/local/lib/nelua/lualib/nelua/analyzer.lua:3409: in function 'nelua.analyzer.analyze'
        /usr/local/lib/nelua/lualib/nelua/runner.lua:187: in function </usr/local/lib/nelua/lualib/nelua/runner.lua:186>
        [C]: in function 'xpcall'
        /usr/local/lib/nelua/lualib/nelua/utils/except.lua:135: in function 'nelua.utils.except.try'
        /usr/local/lib/nelua/lualib/nelua/runner.lua:186: in upvalue 'run'
        /usr/local/lib/nelua/lualib/nelua/runner.lua:262: in function </usr/local/lib/nelua/lualib/nelua/runner.lua:261>
        [C]: in function 'xpcall'
        /usr/local/lib/nelua/lualib/nelua/utils/except.lua:135: in function 'nelua.utils.except.try'
        /usr/local/lib/nelua/lualib/nelua/runner.lua:261: in function 'nelua.runner.run'
        /usr/local/lib/nelua/lualib/nelua.lua:4: in main chunk
        [C]: in function 'require'
        [C]: in ?
stefanos82 commented 8 months ago

Ah, seems like your change in 19917ed has broke my code...was there a particular reason you removed the text from ccinfo?

edubart commented 8 months ago

I removed text field from ccinfo so ## print(inspect(ccinfo)) looks less boilerplate and nicer for users. I recommend some people inspecting it this way so they can found out what compiler information is available at compile time. The information of the text field is already parsed into the ccinfo table, and that field was used more internally, though if your script uses it, you can still retrieve it with ## local _, text = require'nelua.ccompiler'.get_cc_info().

stefanos82 commented 8 months ago

Ah got it!

Thank you for letting me know brother :+1: