Incorrect parsing of `require()` expression (DEF-2522) (SOLVED)

In my code, I have the following line:

local timer_pool = require("lib.timer").get_pool("level")

Your require() parsing code doesn’t stop at ):

1 Like

The require check to figure out which Lua files to include is regex based and not super advanced. It will miss a case such as the one in your example. If you change to this it will work, but yeah, it’s two lines instead of one :slight_smile:

local time = require("lib.timer")
local timer_pool = timer.get_pool("level")

True. I made the change, but the regexp is still broken. It can’t ever be perfect, but it should be fixed along the lines of: /require\s*(?\s*('([^']*)'|"([^"]*)")/

Yup, we should fix this. Also reported here: Parsing of require() statements could be improved (DEF-2522) (SOLVED)

Jira issue: DEF-2522

1 Like

Fixed in Defold 1.2.101

2 Likes