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
Lua: polyglot segmentation splits a function when a [[ ]] long string contains embedded HTML/CSS/JS #2440
detector.py's mid-file language-switching / segmentation runs on text where Lua long-bracket
string literals ([[ ... ]] / [=[ ... ]=]) are not shielded, so a Write([[<!doctype html> ... <style> body { ... } </style> ... ]]) call inside a Lua function gets carved into its own
embedded html/css segment. That segment boundary falls inside the enclosing Lua function,
so _slice_by_keywords receives a segment that starts mid-function and emits a <name>_[Truncated] satellite plus a spurious second __global_context__.
Repro
language-crucible/data/lua/cosmopolitan/fetch.lua (and binarytrees.lua, events.lua, maxmind.lua — all redbean demos that build an HTML page from a [[ ]] heredoc-style string):
local function WriteForm(url)
Write([[<!doctype html>
<style> body { padding: 1em; } ... </style>
<form action="fetch.lua" method="post"> ... </form>
]] % {EscapeHtml(url)})
end
function_data for fetch.lua:
3 WriteForm_[Truncated] <- real span is 3..33
16 __global_context__ <- spurious: this is line 16 of WriteForm's HTML string
22 as
35 main
At the _slice_by_keywords level the file is now clean (verified: after the 2026-08-29 literal-
shield fix the Lua keyword balance for fetch.lua is perfectly zero and WriteForm opens at 3 /
closes at 33). The truncation is introduced upstream, by segmentation seeing the unshielded [[ ]] HTML.
Fix direction
Either (a) prism.py shields Lua long-bracket literals before the polyglot/segment detector
runs, or (b) the segment detector treats a [[ ... ]] span as opaque for Lua the same way it
already respects string boundaries for other languages. (a) is consistent with how string
shielding already protects the rest of the pipeline.
Impact
Accounts for the residual _[Truncated] satellites in lua/function/existence/agree[gitgalaxy]_vs[ctags,tree_sitter] and part of the recall gap in lua/function/existence/agree[ctags,tree_sitter]_vs[gitgalaxy] (binarytrees.lua:WriteForm).
Distinct mechanism from #2437 (that one is a true keyword-count desync; this one is segmentation).
Activity
fix(lua): Mode-D nested-function recall + literal-shield tokenisation
fix(lua): Mode-D nested-function recall + literal-shield tokenisation (…