Skip to content

Commit 4a0f022

Browse files
committed
Remove unnecessary luaTable set expression check and specific exception
1 parent 9860fcc commit 4a0f022

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

src/LuaTransformer.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4996,9 +4996,6 @@ export class LuaTransformer {
49964996
if (callArguments.length !== 2) {
49974997
throw TSTLErrors.ForbiddenLuaTableUseException("Two parameters are required for set().", original);
49984998
}
4999-
if (original.parent.kind !== ts.SyntaxKind.ExpressionStatement) {
5000-
throw TSTLErrors.ForbiddenLuaTableSetExpression(original);
5001-
}
50024999
break;
50035000
}
50045001
}

src/TSTLErrors.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ export const ForbiddenEllipsisDestruction = (node: ts.Node) =>
1313
export const ForbiddenForIn = (node: ts.Node) =>
1414
new TranspileError(`Iterating over arrays with 'for ... in' is not allowed.`, node);
1515

16-
export const ForbiddenLuaTableSetExpression = (node: ts.Node) =>
17-
new TranspileError(
18-
`A '@luaTable' object's 'set()' method can only be used as a Statement, not an Expression.`,
19-
node
20-
);
21-
2216
export const ForbiddenLuaTableNonDeclaration = (node: ts.Node) =>
2317
new TranspileError(`Classes with the '@luaTable' decorator must be declared.`, node);
2418

test/unit/decorators/luaTable.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ test.each([tableLibClass])("LuaTables cannot be constructed with arguments", tab
3535
);
3636
});
3737

38-
test.each([tableLibClass, tableLibInterface])("LuaTable set() cannot be used in an expression position", tableLib => {
39-
expect(() => util.transpileString(tableLib + `const exp = tbl.set("value", 5)`)).toThrowExactError(
40-
TSTLErrors.ForbiddenLuaTableSetExpression(util.nodeStub)
41-
);
42-
});
38+
test.each([tableLibClass, tableLibInterface])(
39+
"LuaTable set() cannot be used in a LuaTable call expression",
40+
tableLib => {
41+
expect(() => util.transpileString(tableLib + `const exp = tbl.set("value", 5)`)).toThrowExactError(
42+
TSTLErrors.UnsupportedProperty("LuaTable", "set", util.nodeStub)
43+
);
44+
}
45+
);
4346

4447
test.each([tableLibClass, tableLibInterface])("LuaTables cannot have other members", tableLib => {
4548
expect(() => util.transpileString(tableLib + `tbl.other()`)).toThrowExactError(

0 commit comments

Comments
 (0)