love.filesystem.load() doesn't catch syntax errors?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- NetherGranite
- Prole
- Posts: 30
- Joined: Wed Jul 11, 2018 11:08 pm
love.filesystem.load() doesn't catch syntax errors?
loadfile() catches syntax errors, but love.filesystem.load() does not, meaning that calls to it have to be wrapped in pcall or xpcall if you are not sure whether the file you are loading is error-free. Is this intentional? I assumed love.filesystem.load() would use loadfile() internally, just with the added functionality of searching for the file in more places; am I wrong?
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: love.filesystem.load() doesn't catch syntax errors?
According to the code, love.filesystem.load should indeed catch most errors: https://bitbucket.org/rude/love/src/992 ... #lines-604
(Also, it uses PhysFS under the hood, like the rest of love.filesystem)
Maybe give us a testcase where it fails for you?
(Also, it uses PhysFS under the hood, like the rest of love.filesystem)
Maybe give us a testcase where it fails for you?
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- NetherGranite
- Prole
- Posts: 30
- Joined: Wed Jul 11, 2018 11:08 pm
Re: love.filesystem.load() doesn't catch syntax errors?
main.lua:
Code: Select all
love.filesystem.load("file.lua")
Code: Select all
a
Code: Select all
Error
main.lua:1: Syntax error: file.lua:2: '=' expected near '<eof>'
Traceback
[C]: in function 'load'
main.lua:1: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
- NetherGranite
- Prole
- Posts: 30
- Joined: Wed Jul 11, 2018 11:08 pm
Re: love.filesystem.load() doesn't catch syntax errors?
Is bumping this thread appropriate?
Re: love.filesystem.load() doesn't catch syntax errors?
There is probably an error, but you're not doing anything with that information. TryNetherGranite wrote: ↑Sat Nov 17, 2018 8:12 pm main.lua:
file.lua:Code: Select all
love.filesystem.load("file.lua")
Running this project throws this error:Code: Select all
a
Code: Select all
Error main.lua:1: Syntax error: file.lua:2: '=' expected near '<eof>' Traceback [C]: in function 'load' main.lua:1: in main chunk [C]: in function 'require' [C]: in function 'xpcall' [C]: in function 'xpcall'
Code: Select all
assert(love.filesystem.load("file.lua"))
Who is online
Users browsing this forum: Bing [Bot] and 3 guests