Inline require statements should throw errors in development or release builds (DEF-3356)

This code does not produce an error (although it should) during development or release builds:

function createType(type)
  -- do logic here...
end

createType(require("my.module"))

The problem arises when we trying to run the release build where it will just open and close immediately without any errors.

The fix is to move the require statement to the top like so:

local myModule = require("my.module")
createType(myModule)

The main problem here is the builds are happening as if everything is good to go, but in reality this prevents the app from running.

1 Like

Upon closer inspection, I noticed this works fine for release builds:

return {
	functional = require("main.utils.functional"),
	logger = require("main.utils.logger"),
	lru = require("main.utils.lru"),
	Stateful = require("main.utils.stateful"),
	table = require("main.utils.object-utils"),
	makeGrid = require("main.utils.make-grid"),
	cloneGrid = require("main.utils.clone-grid"),
	iterateGrid = require("main.utils.iterate-grid")
}

So it isn’t exactly clear as to what the rules are for valid require statements.

2 Likes

The editor parses those to figure out dependencies. It’s done according to a regexp that apprently misses your first case. I’ll file an issue.

4 Likes

issue filed. DEF-3356

2 Likes