Gave it a quick test.
It doesn't seem to respect package.path correctly.
Code: Select all
package.path = package.path .. ';?/init.lua'
require('sstrict')
require('test') -- should end up requiring ./test/init.lua
Code: Select all
Error: sstrict.lua:656: file not found:test
The test module exists and does work correctly without sstrict.lua.
If you want this to be 100% compatible with LÖVE, you have to respect love.filesystem.getRequirePath() as well.
C modules can't be required (file not found), nor can the built-in bit module, nor love modules.
Byte code is not accepted either, it should at least detect and ignore, or maybe warn about byte code.
Some valid LuaJIT syntax is not supported:
Code: Select all
local foo = 0x1ULL -- works
local foo = 0x1LL -- undefined variable 'LL'
local foo = 0x1ull -- undefined variable 'ull'
local foo = 0x1ll -- undefined variable 'll'
local foo = 1ULL -- undefined variable 'ULL'
local foo = 1LL -- undefined variable 'LL'
local foo = 0x1p1 -- undefined variable 'p1'
local foo = 12.5i -- undefined variable 'i'
Parser shits the bed sometimes with some edge cases:
Code: Select all
global1 = 'foo' -- sstrict complains correctly
--[[]] global2 = 'foo' -- not detected
Code: Select all
--[=[
nothing
]=]
-- (undefined variable 'nothing')
Code: Select all
#--[[ (first line of file)
-- rest of file is ignored
The first line in a file should be ignored if it starts with a # (
per specification)
A scenario that is unsolvable with your general approach:
Code: Select all
local function foo()
return baz
end
setfenv(foo, { baz = 'bar' })()
Basing a Lua parser in pattern matching is a nasty can of worms. Unless the subset you want to support is small enough to make it work, you might end up fixing edge cases until the end of times.