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
.luau is parsed with the plain-Lua grammar: four Luau constructs silently truncate or hole a file (exit 0, no warning) #2520
Hi — first, thanks for graphify; we use it daily as the code index an AI agent must consult before it
is allowed to read any source file.
We hit a silent data-loss case on Roblox Luau code and it took a full afternoon to find, so I want to
report it with the exact repro.
What happens
.luau files are extracted with the Lua grammar (ts_module="tree_sitter_lua", extract.py in
0.9.34). Luau is a superset of Lua 5.1, and the constructs it added are not in that grammar. When the
parser meets one, extraction for that file stops there and keeps only the nodes found before it — with exit code 0 and no message on stdout or stderr.
The silence is the actual problem. A partial graph does not look partial: every later query answers
confidently, and "no matching nodes" reads as "this function does not exist".
Minimal repro
A 1981-line .luau file with 25 declared functions, containing exactly two if-expressions:
localSessionStore=ifIS_STUDIOthenStore.MockelseStore-- line 390d.CharacterXp[name] =ifxp>0thenxpelsenil-- line 636
graphify extract . --code-only
as-is: 4 function nodes (the last one declared at line 278, i.e. everything after line 390 is
gone), exit code 0, no warning
after deleting those two lines only: 23 function nodes
Verified on 0.9.33 and 0.9.34, Windows, Python 3.13.
Impact on a real corpus
188 Roblox scripts: 915 of 1078 declared functions present (84.9%). 16 files are truncated,
including one 1064-line file where the last node is at line 1 — 0 of its 16 functions are indexed.
That file happens to own the whole purchase flow, so every query about payments returned nothing and
looked like an answer.
Requests
Parse .luau with a Luau grammar (e.g. tree-sitter-luau) instead of tree-sitter-lua. Luau
constructs that a Lua 5.1 grammar rejects, all common in modern Roblox code:
if-expressions — local x = if c then a else b
type annotations — local x: Foo = ..., function f(a: string): boolean
type aliases and exports — type T = {...}, export type T = ...
generics — function f<T>(...)
type casts — expr :: any
string interpolation — `hi {name}`
compound assignment — x += 1, s ..= "a"
continue
generalized iteration — for k, v in t do
Even with the right grammar, do not fail silently. If a file parses partially, say so — a line
on stderr, a field in the manifest, or a non-zero exit under a flag. We ended up writing our own
checker that compares the highest line reached by any node against the file length, because that
was the only way to see the problem at all. Something like that inside extract would have saved
us the entire investigation.
Happy to test a branch against our corpus — 188 Luau files with a known expected count.
Follow-up from the reporter. I re-measured this today with deletion bisection and a set of
minimal synthetic files, and the central claim of my original report is wrong as written.
If you tried the repro I gave, it would not have reproduced. Sorry — here is the corrected
version, plus a bigger failure I had not found at the time.
All measurements below are on 0.9.34 (PyPI package graphifyy), Windows, Python 3.13.
I checked 0.9.35: its diff does not touch extract.py's Lua path or ts_module, and tree_sitter_lua is untouched, so everything here still applies to 0.9.35.
Every snippet below was run as its own directory containing only that one .luau file, with:
graphify extract . --code-only
and the function nodes counted in the resulting graphify-out/graph.json. Exit code is 0
and nothing is printed to stdout or stderr in every failing case.
1. Retraction: the if-expression is not the problem I said it was
I claimed a Luau if-expression truncates the file. That is too broad. An if-expression
parses fine in every position I tested except one. Each of the four fragments below was put
into its own file containing three plain functions (alpha, beta, gamma) — at top level,
inside alpha's body, as alpha's return value, and as a field assignment between functions.
All four give the full 3 of 3:
-- top level (this is the shape I originally reported as broken - it is NOT)localStore=ifFLAGthen1else2-- inside a function bodylocalx=iftruethen1else2-- after returnreturnifcthen1else2-- assigned to a fieldd.CharacterXp=iftruethen5elsenil
The one position that does break is argument position:
localM= {}
localfunctionalpha()
return1endlocalfunctionbeta()
return2endlocalfunctiongamma(a)
print(ifathen"y" else"n") -- <-- only this line differs from the controlreturn3endlocalfunctiondelta()
return4endreturnM
as written: 2 function nodes (alpha, beta) — everything from the offending line on is gone
replace that one line with print(a): 4 function nodes
So the rule is "an if-expression used as a call argument", not "an if-expression".
2. Retraction: most of the construct list in my original report was wrong
My original issue listed nine Luau constructs as things a Lua 5.1 grammar rejects. I tested
them individually, each inserted between two plain functions in an otherwise identical file. These all extract cleanly, 3 of 3 functions:
construct
example
result
type alias
type Point = { x: number, y: number }
OK
exported type
export type Handler = (string) -> ()
OK
type cast
local v = (M :: any)
OK
annotated local
local cfg: string = "x"
OK
generalized iteration
for k, v in M do end
OK
continue
if i == 2 then continue end
OK
compound assignment
x -= 1, s ..= "a", n //= 2
OK
I specifically want to withdraw compound assignment, which I had recorded internally as a
confirmed cause. I could not reproduce it in any form — plain function body, inside a method,
inside a closure nested in a method. It is fine.
Two from that list do break, in specific shapes, described below.
3. The real, larger stopper: a function-signature type annotation followed by a block comment
Neither part is harmful alone. Together they silently drop functions. This is the whole file —
8 lines, 2 functions:
localfunctionalpha(a: string)
returnaend--[[ c ]]localfunctionbeta(b)
returnbend
Result: 1 of 2 (alpha is gone). The full control matrix, same file, one thing changed each time:
signature annotation
block comment
functions found
(a: string)
--[[ c ]]
1 of 2
(a)
--[[ c ]]
2 of 2
(a: string)
(removed)
2 of 2
(a: string)
-- c (line comment)
2 of 2
So the block comment is the trigger and the annotation is the defect — removing either one
fixes it. A return-type annotation (local function alpha(a): boolean) also triggers loss,
though it takes out a different function, so I would not over-specify which nodes disappear;
the reliable statement is that functions are lost.
The collateral is wider than just the annotated function. In this file, alpha is annotated, plain1 is not, delta is annotated, and a block comment follows all three:
Result: 2 of 5 — alpha, plain1 and delta are all gone, including the un-annotated one.
Everything declared before the block comment is lost.
Since type-annotated signatures and block-comment doc headers are both completely ordinary in
Roblox code, they co-occur constantly, and each occurrence silently deletes a run of functions.
4. The biggest single loss, not reported before: an escaped quote inside an interpolated string
This one cost us the most and was not in my original report at all. Plain string interpolation
is survivable. An interpolated string containing an escaped quote desynchronizes the parse.
localM= {}
localfunctionbefore1()
return1endlocalfunctionbefore2()
return2endlocalfunctionbad(name)
error(`[{name}]: \"listener\" missing`) -- <-- the only problematic lineendlocalfunctionafter1()
return3endlocalfunctionafter2()
return4endlocalfunctionafter3()
return5endreturnM
as written: 2 of 6 (before1, before2) — everything from that line to EOF is gone
same file with plain interpolation, error(`[{name}]: listener missing`): 6 of 6
same file with an ordinary string carrying the same escapes, error("[" .. name .. "]: \"listener\" missing"): 6 of 6
In a small file it truncates to EOF. In a large real file the parser eventually resynchronizes,
which is worse, because the result is not a truncated file but a file with holes — and a
hole is invisible to any "last node line vs file length" check, including the one I wrote and
described in the original issue. In one 2268-line file of ours, a single such string produced
two holes (lines 246-1106 and 1198-1657) and hid 26 of that file's 44 top-level functions,
while the file's last node still sat at line 2065, so it did not look truncated at all.
5. Generics
function f<T>(v: T): T does break, and this part of my original report stands:
2 of 3 as written; 3 of 3 after changing the signature to local function alpha(v).
(The generic function on its own in a file gives 0 of 1.) I list this separately because I only
hit it in probes, not in our own corpus.
6. Corrected impact numbers
My original figures ("915 of 1078 declared functions, 84.9%") mixed two different things
together and I should not have reported them that way. Nested functions are not indexed, which
is a documented limit and not a bug, but I was counting them as missing. Counting only
non-nested functions, against a corpus of 188 Luau scripts:
before working around any of the above: 889 of 961 non-nested functions present
after working around all of it locally (pre-processing the sources before extraction): 961 of 961, with all 987 nodes pointing at the correct declaration line
Per file, worst cases: 0 of 15 -> 15 of 15, 4 of 23 -> 23 of 23, 20 of 32 -> 32 of 32, 18 of 44 -> 44 of 44.
And a correction I owe you specifically: in the original issue I said three of our files
were truncated by some unidentified construct. That was wrong. Those three files were never
truncated — their code simply lives inside one enclosing function, and nested functions are
not indexed. That is your documented behaviour working as intended, and I misread it as a
parser failure. There is no third unknown stopper.
7. What I would ask for, unchanged in substance
Parse .luau with a Luau grammar rather than tree_sitter_lua. The corrected list of
things that actually break is much shorter than the one I gave originally: if-expression in
argument position, function-signature type annotations when a block comment follows, generics,
and interpolated strings containing escaped quotes.
Do not fail silently, which remains the real problem. All of the above exit 0 with no
output. A partial file does not look partial, so every later query answers confidently and
"no matching nodes" is indistinguishable from "this function does not exist". Even a count of
tree-sitter ERROR nodes per file, surfaced on stderr or in the manifest, would have saved the
whole investigation. Please note that a truncation check is not sufficient — case 4 above
leaves holes in the middle of a file that reaches EOF normally.
Happy to test a branch: we have a 188-file Luau corpus with per-file expected counts and a
checker that compares declared functions against graph nodes, so I can give you a before/after
number on a real codebase within a few minutes of a push.
changed the title [-]`.luau` files are parsed with the plain-Lua grammar, so a Luau if-expression silently truncates the whole file[/-][+]`.luau` is parsed with the plain-Lua grammar: four Luau constructs silently truncate or hole a file (exit 0, no warning)[/+]on Aug 7, 2026
Re-measured today on 0.9.39 (Windows, Python 3.14), same corpus as before.
First: half of this report is now fixed, and it is the half that hurt most
The Kotlin work in 0.9.37 (#2551) also made partial extraction visible for Luau. Our corpus now
prints this by itself, with no flag:
warning: 8 file(s) had syntax errors and may be partially extracted:
<module-a>.server.luau (first error at line 390),
<module-b>.server.luau (first error at line 173),
<module-c>.server.luau (first error at line 1),
<module-d>.luau (first error at line 253),
<module-e>.client.luau (first error at line 166) (+3 more) (#2551)
(File names replaced with placeholders — this is a closed-source game. Line numbers, counts and
everything else are verbatim.)
That is exactly what I asked for in point 2 of my previous comment, and the file list is accurate —
it names the same files we had to pre-process. The original failure mode (a partial graph that looks
complete, where "no matching nodes" is indistinguishable from "this function does not exist") is
gone, because the run now says so out loud. Thank you — that alone removes the class of silent loss.
The retry fix in the same release (#2543) matters here too: a file that failed extraction is no
longer stamped up-to-date forever.
What remains: the grammar itself
With the warning acknowledged, the numbers on 0.9.39 are unchanged, because .luau is still parsed
with tree_sitter_lua:
raw corpus, 189 Luau files: 894 of 966 non-nested functions (92.5%) — 72 missing
same corpus after pre-processing the sources locally: 966 of 966
worst file: 0 of 15 functions (1064 lines; first error at line 173, highest node at line 1)
next worst: 18 of 44, 4 of 23, 20 of 32
The constructs are the corrected four from my previous comment, not the nine from the original
issue: an if-expression in argument position, a function-signature type annotation when a block
comment follows, generics <T>, and an interpolated string containing an escaped quote.
A concrete path, if it helps
tree-sitter-luau is on PyPI (1.2.0). If the blocker is bundling policy rather than the mapping
itself, say so and I will stop asking for the grammar and ask for something cheaper instead — for
example allowing ts_module to be overridden per extension in config, so a project can point .luau at an installed grammar without you shipping it.
Offer stands and is cheap for you: 189 Luau files with per-file expected counts and a checker that
compares declared functions against graph nodes. Push a branch and I will send a before/after table
within minutes.
Activity
arnasmmm commentedon Aug 7, 2026
Follow-up from the reporter. I re-measured this today with deletion bisection and a set of
minimal synthetic files, and the central claim of my original report is wrong as written.
If you tried the repro I gave, it would not have reproduced. Sorry — here is the corrected
version, plus a bigger failure I had not found at the time.
All measurements below are on 0.9.34 (PyPI package
graphifyy), Windows, Python 3.13.I checked 0.9.35: its diff does not touch
extract.py's Lua path orts_module, andtree_sitter_luais untouched, so everything here still applies to 0.9.35.Every snippet below was run as its own directory containing only that one
.luaufile, with:and the function nodes counted in the resulting
graphify-out/graph.json. Exit code is 0and nothing is printed to stdout or stderr in every failing case.
1. Retraction: the if-expression is not the problem I said it was
I claimed a Luau if-expression truncates the file. That is too broad. An if-expression
parses fine in every position I tested except one. Each of the four fragments below was put
into its own file containing three plain functions (
alpha,beta,gamma) — at top level,inside
alpha's body, asalpha's return value, and as a field assignment between functions.All four give the full 3 of 3:
The one position that does break is argument position:
alpha,beta) — everything from the offending line on is goneprint(a): 4 function nodesSo the rule is "an if-expression used as a call argument", not "an if-expression".
2. Retraction: most of the construct list in my original report was wrong
My original issue listed nine Luau constructs as things a Lua 5.1 grammar rejects. I tested
them individually, each inserted between two plain functions in an otherwise identical file.
These all extract cleanly, 3 of 3 functions:
type Point = { x: number, y: number }export type Handler = (string) -> ()local v = (M :: any)local cfg: string = "x"for k, v in M do endcontinueif i == 2 then continue endx -= 1,s ..= "a",n //= 2I specifically want to withdraw compound assignment, which I had recorded internally as a
confirmed cause. I could not reproduce it in any form — plain function body, inside a method,
inside a closure nested in a method. It is fine.
Two from that list do break, in specific shapes, described below.
3. The real, larger stopper: a function-signature type annotation followed by a block comment
Neither part is harmful alone. Together they silently drop functions. This is the whole file —
8 lines, 2 functions:
Result: 1 of 2 (
alphais gone). The full control matrix, same file, one thing changed each time:(a: string)--[[ c ]](a)--[[ c ]](a: string)(a: string)-- c(line comment)So the block comment is the trigger and the annotation is the defect — removing either one
fixes it. A return-type annotation (
local function alpha(a): boolean) also triggers loss,though it takes out a different function, so I would not over-specify which nodes disappear;
the reliable statement is that functions are lost.
The collateral is wider than just the annotated function. In this file,
alphais annotated,plain1is not,deltais annotated, and a block comment follows all three:Result: 2 of 5 —
alpha,plain1anddeltaare all gone, including the un-annotated one.Everything declared before the block comment is lost.
Since type-annotated signatures and block-comment doc headers are both completely ordinary in
Roblox code, they co-occur constantly, and each occurrence silently deletes a run of functions.
4. The biggest single loss, not reported before: an escaped quote inside an interpolated string
This one cost us the most and was not in my original report at all. Plain string interpolation
is survivable. An interpolated string containing an escaped quote desynchronizes the parse.
before1,before2) — everything from that line to EOF is goneerror(`[{name}]: listener missing`): 6 of 6error("[" .. name .. "]: \"listener\" missing"): 6 of 6In a small file it truncates to EOF. In a large real file the parser eventually resynchronizes,
which is worse, because the result is not a truncated file but a file with holes — and a
hole is invisible to any "last node line vs file length" check, including the one I wrote and
described in the original issue. In one 2268-line file of ours, a single such string produced
two holes (lines 246-1106 and 1198-1657) and hid 26 of that file's 44 top-level functions,
while the file's last node still sat at line 2065, so it did not look truncated at all.
5. Generics
function f<T>(v: T): Tdoes break, and this part of my original report stands:2 of 3 as written; 3 of 3 after changing the signature to
local function alpha(v).(The generic function on its own in a file gives 0 of 1.) I list this separately because I only
hit it in probes, not in our own corpus.
6. Corrected impact numbers
My original figures ("915 of 1078 declared functions, 84.9%") mixed two different things
together and I should not have reported them that way. Nested functions are not indexed, which
is a documented limit and not a bug, but I was counting them as missing. Counting only
non-nested functions, against a corpus of 188 Luau scripts:
961 of 961, with all 987 nodes pointing at the correct declaration line
Per file, worst cases: 0 of 15 -> 15 of 15, 4 of 23 -> 23 of 23,
20 of 32 -> 32 of 32, 18 of 44 -> 44 of 44.
And a correction I owe you specifically: in the original issue I said three of our files
were truncated by some unidentified construct. That was wrong. Those three files were never
truncated — their code simply lives inside one enclosing function, and nested functions are
not indexed. That is your documented behaviour working as intended, and I misread it as a
parser failure. There is no third unknown stopper.
7. What I would ask for, unchanged in substance
.luauwith a Luau grammar rather thantree_sitter_lua. The corrected list ofthings that actually break is much shorter than the one I gave originally: if-expression in
argument position, function-signature type annotations when a block comment follows, generics,
and interpolated strings containing escaped quotes.
output. A partial file does not look partial, so every later query answers confidently and
"no matching nodes" is indistinguishable from "this function does not exist". Even a count of
tree-sitter ERROR nodes per file, surfaced on stderr or in the manifest, would have saved the
whole investigation. Please note that a truncation check is not sufficient — case 4 above
leaves holes in the middle of a file that reaches EOF normally.
Happy to test a branch: we have a 188-file Luau corpus with per-file expected counts and a
checker that compares declared functions against graph nodes, so I can give you a before/after
number on a real codebase within a few minutes of a push.
[-]`.luau` files are parsed with the plain-Lua grammar, so a Luau if-expression silently truncates the whole file[/-][+]`.luau` is parsed with the plain-Lua grammar: four Luau constructs silently truncate or hole a file (exit 0, no warning)[/+]arnasmmm commentedon Aug 11, 2026
Re-measured today on 0.9.39 (Windows, Python 3.14), same corpus as before.
First: half of this report is now fixed, and it is the half that hurt most
The Kotlin work in 0.9.37 (#2551) also made partial extraction visible for Luau. Our corpus now
prints this by itself, with no flag:
(File names replaced with placeholders — this is a closed-source game. Line numbers, counts and
everything else are verbatim.)
That is exactly what I asked for in point 2 of my previous comment, and the file list is accurate —
it names the same files we had to pre-process. The original failure mode (a partial graph that looks
complete, where "no matching nodes" is indistinguishable from "this function does not exist") is
gone, because the run now says so out loud. Thank you — that alone removes the class of silent loss.
The retry fix in the same release (#2543) matters here too: a file that failed extraction is no
longer stamped up-to-date forever.
What remains: the grammar itself
With the warning acknowledged, the numbers on 0.9.39 are unchanged, because
.luauis still parsedwith
tree_sitter_lua:The constructs are the corrected four from my previous comment, not the nine from the original
issue: an if-expression in argument position, a function-signature type annotation when a block
comment follows, generics
<T>, and an interpolated string containing an escaped quote.A concrete path, if it helps
tree-sitter-luauis on PyPI (1.2.0). If the blocker is bundling policy rather than the mappingitself, say so and I will stop asking for the grammar and ask for something cheaper instead — for
example allowing
ts_moduleto be overridden per extension in config, so a project can point.luauat an installed grammar without you shipping it.Offer stands and is cheap for you: 189 Luau files with per-file expected counts and a checker that
compares declared functions against graph nodes. Push a branch and I will send a before/after table
within minutes.
fix(extract): gate the #2551 partial-parse warning on plausible symbo…
feat(extract): resolve Luau require() through Rojo project trees (Gra…
fix(extract): treat Luau as Lua family in the engine's Lua-only paths (…