fix: hoist local M = {} above closures to resolve M.get_theme
_dispatch_event captures M at closure-definition time; with M declared further down the file, the capture resolved to global M (nil), causing 'attempt to index a nil value (global M)' every frame the panel was open and a mouse event was dispatched. Hoisting the table declaration above the dispatch helpers fixes the resolution at compile time.
This commit is contained in:
10
init.lua
10
init.lua
@@ -34,6 +34,11 @@
|
||||
-- Module-level state (all local — no globals)
|
||||
-- -----------------------------------------------------------------------
|
||||
|
||||
-- Module-table declared early so closures in module-local helpers below
|
||||
-- can reference M.X functions. Method assignments (function M.x() ... end)
|
||||
-- still land further down once the public surface section starts.
|
||||
local M = {}
|
||||
|
||||
local widgets = {} -- widget_id (string) → widget_def table
|
||||
local active = nil -- active widget_id or nil
|
||||
local theme = {} -- merged DEFAULT_THEME + overrides
|
||||
@@ -187,11 +192,8 @@ local function _dispatch_event(event)
|
||||
end
|
||||
|
||||
-- -----------------------------------------------------------------------
|
||||
-- Public module table
|
||||
-- Public API (M declared at top of file so closures above can reference it)
|
||||
-- -----------------------------------------------------------------------
|
||||
|
||||
local M = {}
|
||||
|
||||
-- -----------------------------------------------------------------------
|
||||
-- Registry / Lifecycle
|
||||
-- -----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user