Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changes/61-bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
align w/ breaking changes to AST function nodes
2 changes: 1 addition & 1 deletion foreman.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tools]
lute = { source = "luau-lang/lute", version = "=0.1.0-nightly.20260124" }
lute = { source = "luau-lang/lute", version = "=0.1.0-nightly.20260130" }
stylua = { source = "JohnnyMorganz/StyLua", version = "2.0.2" }
2 changes: 1 addition & 1 deletion frontend/src/tests/TreeNode.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ describe("TreeNode", () => {
describe("array type inference edge cases", () => {
test("handles punctuated arrays", () => {
const punctuatedNode = {
_astType: "AstFunctionBody",
_astType: "AstExprFunction",
parameters: [
// Use proper Punctuated<AstLocal> structures
{
Expand Down
33 changes: 11 additions & 22 deletions frontend/src/utils/astTypeDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,13 @@ export const astTypeDefinitions: Record<string, ASTTypeDefinition> = {
],
},

AstFunctionBody: {
AstExprFunction: {
properties: [
{ name: "location", type: "span" },
{ name: "kind", type: '"expr"' },
{ name: "tag", type: '"function"' },
{ name: "attributes", type: "{ AstAttribute }" },
{ name: "functionkeyword", type: "Token", generic: 'Token<"function">' },
{
name: "opengenerics",
type: "Token",
Expand All @@ -266,8 +271,8 @@ export const astTypeDefinitions: Record<string, ASTTypeDefinition> = {
generic: 'Token<">">',
optional: true,
},
{ name: "self", type: "AstLocal", optional: true },
{ name: "openparens", type: "Token", generic: 'Token<"(">' },
{ name: "self", type: "AstLocal", optional: true },
{
name: "parameters",
type: "Punctuated",
Expand Down Expand Up @@ -299,17 +304,6 @@ export const astTypeDefinitions: Record<string, ASTTypeDefinition> = {
],
},

AstExprAnonymousFunction: {
properties: [
{ name: "location", type: "span" },
{ name: "kind", type: '"expr"' },
{ name: "tag", type: '"function"' },
{ name: "attributes", type: "{ AstAttribute }" },
{ name: "functionkeyword", type: "Token", generic: 'Token<"function">' },
{ name: "body", type: "AstFunctionBody" },
],
},

AstExprTableItemList: {
properties: [
{ name: "location", type: "span" },
Expand Down Expand Up @@ -459,7 +453,7 @@ export const astTypeDefinitions: Record<string, ASTTypeDefinition> = {
"AstExprCall",
"AstExprIndexName",
"AstExprIndexExpr",
"AstExprAnonymousFunction",
"AstExprFunction",
"AstExprTable",
"AstExprUnary",
"AstExprBinary",
Expand Down Expand Up @@ -683,10 +677,8 @@ export const astTypeDefinitions: Record<string, ASTTypeDefinition> = {
{ name: "location", type: "span" },
{ name: "kind", type: '"stat"' },
{ name: "tag", type: '"function"' },
{ name: "attributes", type: "{ AstAttribute }" },
{ name: "functionkeyword", type: "Token", generic: 'Token<"function">' },
{ name: "name", type: "AstExpr" },
{ name: "body", type: "AstFunctionBody" },
{ name: "func", type: "AstExprFunction" },
],
},

Expand All @@ -695,11 +687,9 @@ export const astTypeDefinitions: Record<string, ASTTypeDefinition> = {
{ name: "location", type: "span" },
{ name: "kind", type: '"stat"' },
{ name: "tag", type: '"localfunction"' },
{ name: "attributes", type: "{ AstAttribute }" },
{ name: "localkeyword", type: "Token", generic: 'Token<"local">' },
{ name: "functionkeyword", type: "Token", generic: 'Token<"function">' },
{ name: "name", type: "AstLocal" },
{ name: "body", type: "AstFunctionBody" },
{ name: "func", type: "AstExprFunction" },
],
},

Expand Down Expand Up @@ -757,9 +747,8 @@ export const astTypeDefinitions: Record<string, ASTTypeDefinition> = {
optional: true,
},
{ name: "type", type: "Token", generic: 'Token<"type">' },
{ name: "functionkeyword", type: "Token", generic: 'Token<"function">' },
{ name: "name", type: "Token" },
{ name: "body", type: "AstFunctionBody" },
{ name: "body", type: "AstExprFunction" },
],
},

Expand Down
16 changes: 9 additions & 7 deletions lua_helpers/typeAnnotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ local typeDefinitions = {

-- Expression/Statement specific
["expression"] = "AstExpr",
["func"] = "AstExpr",
["func"] = "AstExprFunction",
["condition"] = "AstExpr",
["from"] = "AstExpr",
["to"] = "AstExpr",
Expand Down Expand Up @@ -210,11 +210,12 @@ local function resolveAmbiguousTags(node)
-- AstTypeFunction has returnarrow and kind="type"
if kind == "type" or node.returnarrow then
return "AstTypeFunction"
-- AstStatFunction has name and kind="stat"
elseif kind == "stat" or node.name then
-- AstStatFunction has name field and kind="stat" (but not func field directly on it)
elseif kind == "stat" then
return "AstStatFunction"
else
return "AstExprAnonymousFunction"
-- AstExprFunction (consolidated from old AstExprAnonymousFunction + AstFunctionBody)
return "AstExprFunction"
end
elseif tag == "group" then
-- AstExprGroup has expression and kind="expr", AstTypeGroup has type and kind="type"
Expand Down Expand Up @@ -286,9 +287,10 @@ local function resolveAmbiguousKeys(nodeKey, node, parentNode, parentKey)

-- Ambiguous keys that need context-aware resolution:
if nodeKey == "body" then
-- AstStatBlock vs AstFunctionBody vs { AstStat } for AstStatDo
if node.openparens then
return "AstFunctionBody"
-- AstStatBlock vs AstExprFunction (for AstStatTypeFunction) vs { AstStat } for AstStatDo
if node.functionkeyword and node.openparens then
-- This is AstExprFunction (used in AstStatTypeFunction.body)
return "AstExprFunction"
elseif node.statements then
return "AstStatBlock"
else
Expand Down
10 changes: 5 additions & 5 deletions lua_tests/helpers/typeAnnotationTestHelpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ typeAnnotationVisitor.visitStatFunction = function(node: luau.AstStatFunction)
return true
end

typeAnnotationVisitor.visitExprAnonymousFunction = function(node: luau.AstExprAnonymousFunction)
verifyOutput(node, "visitAnonymousFunction", node._astType == "AstExprAnonymousFunction")
typeAnnotationVisitor.visitExprFunction = function(node: luau.AstExprFunction)
verifyOutput(node, "visitExprFunction", node._astType == "AstExprFunction")
return true
end

Expand Down Expand Up @@ -305,7 +305,7 @@ local ambiguousTagTestCases = {
{ { tag = "conditional", kind = "expr" }, "AstExprIfElse", "if expression" },
{ { tag = "function", kind = "type", returnarrow = {} }, "AstTypeFunction", "type function" },
{ { tag = "function", kind = "stat", name = {} }, "AstStatFunction", "function statement" },
{ { tag = "function", kind = "expr" }, "AstExprAnonymousFunction", "anonymous function" },
{ { tag = "function", kind = "expr" }, "AstExprFunction", "expression function" },
{ { tag = "group", kind = "expr", expression = {} }, "AstExprGroup", "expression group" },
{ { tag = "group", kind = "type", type = {} }, "AstTypeGroup", "type group" },
{ { tag = "local", kind = "expr", token = {}, upvalue = false }, "AstExprLocal", "local expression" },
Expand All @@ -316,14 +316,14 @@ local ambiguousTagTestCases = {

local ambiguousKeyTestCases = {
-- {key, node, parent, expectedType, description}
{ "body", { openparens = {} }, {}, "AstFunctionBody", "function body" },
{ "body", { functionkeyword = {}, openparens = {} }, {}, "AstExprFunction", "function body (AstStatTypeFunction)" },
{ "body", { statements = {} }, { tag = "if" }, "AstStatBlock", "if body" },
{ "operand", { tag = "call" }, { operator = {}, tag = "unary" }, "AstExpr", "unary operand" },
{ "self", {}, {}, "AstLocal", "self parameter" },
{ "self", {}, { tag = "call" }, "boolean", "no self parameter" },
{ "condition", { tag = "binary" }, {}, "AstExpr", "condition expression" },
{ "expression", { tag = "call" }, {}, "AstExpr", "expression" },
{ "func", { tag = "function" }, {}, "AstExpr", "function expression" },
{ "func", { tag = "function" }, {}, "AstExprFunction", "function expression" },
{ "key", {}, { kind = "record", istableitem = true }, "Token", "record key" },
{ "key", {}, { kind = "indexer" }, "AstType", "indexer key" },
{ "key", {}, { kind = "general", istableitem = true }, "AstExpr", "general key" },
Expand Down
2 changes: 1 addition & 1 deletion rokit.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tools]
lute = "luau-lang/lute@0.1.0-nightly.20251213"
lute = "luau-lang/lute@0.1.0-nightly.20260130"
stylua = "JohnnyMorganz/StyLua@2.0.2"