You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fields added after a forward table assignment are not inferred #1272
A table assigned after a forward local declaration does not gain fields assigned later. This produces undefined-field at the assignment and causes exported module fields to be considered nullable.
The equivalent code with declaration and table initialization in one statement works without diagnostics.
This affects LuaSnip: luasnip/config.lua forward-declares c, assigns its table later, and then aliases c.setup = c.set_config. As a result, normal user configuration gets function require('luasnip').setup may be nil [need-check-nil].
split/config.lua:9:8: Undefined field `setup`. [undefined-field]
split/api.lua:3:37: Undefined field `setup`. [undefined-field]
client.lua:1:1: function require('split.api').setup may be nil [need-check-nil]
Expected behavior
No diagnostics. config is definitely assigned the table before config.setup is added, and setup is definitely assigned before the module is returned.
Changing only the first two declarations to initialize the local directly makes the diagnostics disappear:
I opened L3MON4D3/LuaSnip#1454 with a narrow annotation workaround. It explicitly types LuaSnip's forward-declared config table, which removes the false setup may be nil diagnostic in both the real plugin consumer and a minimal test.
This issue should remain open because the annotation only works around the underlying inference problem.
Activity
oriori1703 commentedon Oct 3, 2026
I opened L3MON4D3/LuaSnip#1454 with a narrow annotation workaround. It explicitly types LuaSnip's forward-declared config table, which removes the false
setup may be nildiagnostic in both the real plugin consumer and a minimal test.This issue should remain open because the annotation only works around the underlying inference problem.