Skip to content

Lua class_start heuristic (Capitalised = {) also matches ALL_CAPS data tables #2439

Closed

Description

@squid-protocol

Summary

lua class_start (^[ \t]*---@class\s+(\w+)|^[ \t]*(?:local )?(?:export )?(?:type )?([A-Z]\w*)(?=\s*=\s*\{))
is a heuristic for the Lua proto-table OOP idiom (Account = {}; Account.__index = Account; ...).
The second alternative -- a Capitalised name assigned a table literal -- also fires on plain
ALL_CAPS / Capitalised DATA tables:

local FISH     = { {0,0,0,1,...}, ... }   -- redis/life.lua: a Game-of-Life cell pattern
local EXPLODE  = { ... }                  -- ditto
local AA = {}   local K = {}   local A = {}   -- test fixtures

Lua has no class syntax, so tree-sitter-lua (no class node) and Universal Ctags (no class kind)
both report 0 -- there is no ground-truth tool to catch this, only the tri-comparison
lua/class/existence/agree[gitgalaxy]_vs[ctags,tree_sitter] shape (14 occurrences, validated
2026-08-29 as "GitGalaxy heuristic, no corroborating tool").

Options

  • Require a proto-table tell within a bounded window: a following .__index, :new, setmetatable(<name>,
    or function <name>[.:] line. (Bounded-lookahead-friendly.)
  • Or treat lua like css/html -- add it to _CLASS_EXTRACTION_OUT_OF_SCOPE in
    tree_sitter_accuracy_audit.py and render lua class precision as N/A rather than 0.0%.

Found by

tri-comparison-ledger-sweep (lua), 2026-08-29.

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions