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:
Calic
2026-06-14 00:05:24 +02:00
parent 64aa1c8777
commit a445b895ee

View File

@@ -34,6 +34,11 @@
-- Module-level state (all local — no globals) -- 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 widgets = {} -- widget_id (string) → widget_def table
local active = nil -- active widget_id or nil local active = nil -- active widget_id or nil
local theme = {} -- merged DEFAULT_THEME + overrides local theme = {} -- merged DEFAULT_THEME + overrides
@@ -187,11 +192,8 @@ local function _dispatch_event(event)
end end
-- ----------------------------------------------------------------------- -- -----------------------------------------------------------------------
-- Public module table -- Public API (M declared at top of file so closures above can reference it)
-- ----------------------------------------------------------------------- -- -----------------------------------------------------------------------
local M = {}
-- ----------------------------------------------------------------------- -- -----------------------------------------------------------------------
-- Registry / Lifecycle -- Registry / Lifecycle
-- ----------------------------------------------------------------------- -- -----------------------------------------------------------------------