Repository navigation
fix(lua): one-line functions, [[ ]] segmentation splits, class heuristic - #2444
Merged
Merged
Conversation
Follow-on to #2441, closing three issues the lua tri-comparison sweep filed. opener/closer count, so their net Mode-D scope change is <= 0: the primary scan filed them as global dust and the `function_opener` pass skipped them (`depth_before_line[i] <= 0` gate). Affected plain names, redefinitions, method heads, and every declaration nested in a bare `do` block. Fixed by extending `function_opener` to top-level self-closing declarations, lua-scoped so ruby/matlab/livecode keep the strict gate. The Anonymous_Block name-borrow fallback is taught to skip a completed one-liner so an adjacent `coroutine.wrap(function() ... end)` closure isn't mislabeled with the previous line's name. (The issue's "dotted head" framing was a misdiagnosis -- `_extract_semantic_name` already resolves `a.b.c.f1` / `a:deep`.) raw text, so the HTML inside `Write([[<!doctype html> ... ]])` in redbean demo files was carved into a `css` segment mid-function, producing a `<name>_[Truncated]` satellite. Fixed by running the trigger scan against a view where lua long-bracket literals are blanked to same-length filler (offsets + line numbers preserved; segment slicing unchanged). Same mask added to prism's `_partition_embedded_languages`. tables (`local FISH = { ... }`, one-letter fixtures). Fixed by requiring a proto-table tell -- `function Name[.:]`, `Name.__index`, `setmetatable(..., Name)`, or `Name[.:]new` -- within a bounded window for the heuristic branch; the explicit `---@class` branch is never gated. Measured (`tree_sitter_accuracy_audit.py --lang lua`): found_functions 557 -> 618, extra_functions 7 -> 1, extra_classes 14 -> 1, args_exact_match 516 -> 572. Lua recall 89.8% -> 99.7%, precision 98.8% -> 99.8%. Both golden masters re-blessed (lua files + topological ripple only), lua baseline + summary table regenerated, ledger verdicts + chart + points-of-interest regenerated (`--all`), `docs/language_status/lua.md` §9 updated. One residual, not filed: a `\z` line-continuation inside a single-quoted string defeats the newline-bounded literal shield (`events.lua`), a pre-existing cross-language gap -- the last lua `_[Truncated]` in the corpus. #2437 has no remaining lua repro. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019Zm1uVBpVEZJ9SB7bWFR8S
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-on to #2441, closing three issues the lua tri-comparison sweep filed.
#2438 — one-line function declarations never emitted
A one-liner
function a:x (x) return x+self.i endhas an equal opener/closer count → net Mode-Dscope change ≤ 0, so the primary scan filed it as global dust and the
function_openerpassskipped it (
depth_before_line[i] <= 0gate). Affected plain names, redefinitions(
function deep (n) ... end), method heads, and every declaration nested in a baredoblock (
doisn't a Mode-D opener). Fixed by extendingfunction_openerto top-levelself-closing declarations, lua-scoped so ruby/matlab/livecode keep the strict gate. The
Anonymous_Block name-borrow fallback now skips a completed one-liner so an adjacent
coroutine.wrap(function() ... end)closure isn't mislabeled with the previous line's name.(The issue's "dotted head" framing was a misdiagnosis —
_extract_semantic_namealreadyresolves
a.b.c.f1/a:deep.)#2440 — polyglot segmentation split a function at embedded markup
detector.py's_partition_segmentsscanned for^\s*<style/^\s*<scripton raw text, sothe HTML inside
Write([[<!doctype html> … <style> … ]])in the redbean demo files(
fetch.lua,binarytrees.lua,maxmind.lua) was carved into acsssegment mid-function,producing a
<name>_[Truncated]satellite. Fixed by scanning triggers against a view where lualong-bracket literals are blanked to same-length filler (byte offsets and line numbers preserved;
segment slicing still uses the untouched text). Same mask added to prism's
_partition_embedded_languages.#2439 — class_start heuristic matched ALL_CAPS data tables
Lua has no
classkeyword; theName = {heuristic fired onlocal FISH = { ... }(Game-of-Life patterns),
local Arr = {}, one-letter test fixtures. Fixed by requiring aproto-table tell —
function Name[.:],Name.__index,setmetatable(…, Name), orName[.:]new— within a bounded window for the heuristic branch. The explicit
---@class(LuaLS annotation)branch is never gated. Only
tracegc.lua:M(a real module table withfunction M.start/function M.stop/return M) survives.Measured effect
tree_sitter_accuracy_audit.py --lang lua:found_functionsextra_functions(lower better)extra_classes(lower better)args_exact_matchLua recall 89.8% → 99.7%, function precision 98.8% → 99.8%.
Differential Scan
coordinate ripple on a handful of unrelated files.
crucible_check.py --mode bothPASS.tests/tree_sitter_accuracy_baseline_lua.jsonregenerated (--regenerate, all gated metricsimproved). Summary table in
language_standards.pyupdated.tree_sitter_accuracy_audit.py --all --ci31/31 OK.tri_comparison_chart.py --all --ciOK.tests/extraction(6808) +tests/core_enginepass; ruby / matlab / livecode extraction(the other
function_openerlanguages) unaffected.audit_check.pyclean.--all --write).docs/language_status/lua.md§9 updated (now documents 5 fixed defects across two PRs).Residual
Not filed — one
\zline-continuation inside a single-quoted string defeats the newline-boundedliteral shield (
events.lua), a pre-existing cross-language gap and the last lua_[Truncated]in the corpus. #2437 has no remaining lua repro.
Closes #2438, closes #2439, closes #2440.
🤖 Generated with Claude Code
https://claude.ai/code/session_019Zm1uVBpVEZJ9SB7bWFR8S