Code: Select all
local foo = require("libs.foo")
local foo2 = require("libs.foo")
if foo2 ~= foo then
print("This will not happen")
end
local foo3 = require("libs/foo")
if foo3 ~= foo then
print("Oh my. Using a slash instead of a dot is broken.")
end
Lua keeps track of this in a table somewhere. In other news, Lua supports multiple syntaxes for require. One of these syntaxes allows a "/" to denote directories. One of the other syntactic behaviors allows a "." to denote directories.
Long story short, if you mix and match the "." syntax with the "/" syntax, require will execute the required script multiple times.
This cost me 3 hours. Remember kids: Stay consistent with your require syntax!