@@ -2169,7 +2169,6 @@ export class LuaTransformer {
21692169 const ownerType = this . checker . getTypeAtLocation ( expression . expression . expression ) ;
21702170 const classDecorators = tsHelper . getCustomDecorators ( ownerType , this . checker ) ;
21712171 if ( classDecorators . has ( DecoratorKind . LuaTable ) ) {
2172- this . validateLuaTableCall ( expression ) ;
21732172 return this . transformLuaTableExpressionAsExpressionStatement ( expression ) ;
21742173 }
21752174 }
@@ -4249,7 +4248,6 @@ export class LuaTransformer {
42494248 const classDecorators = tsHelper . getCustomDecorators ( ownerType , this . checker ) ;
42504249
42514250 if ( classDecorators . has ( DecoratorKind . LuaTable ) ) {
4252- this . validateLuaTableCall ( node ) ;
42534251 return this . transformLuaTableCallExpression ( node ) ;
42544252 }
42554253
@@ -4338,7 +4336,6 @@ export class LuaTransformer {
43384336 const ownerDecorators = tsHelper . getCustomDecorators ( ownerType , this . checker ) ;
43394337
43404338 if ( ownerDecorators . has ( DecoratorKind . LuaTable ) ) {
4341- this . validateLuaTableCall ( node ) ;
43424339 return this . transformLuaTableCallExpression ( node ) ;
43434340 }
43444341
@@ -4980,34 +4977,35 @@ export class LuaTransformer {
49804977 }
49814978 }
49824979
4983- protected validateLuaTableCall ( expression : ts . CallExpression ) : void {
4984- const [ , methodName ] = this . parseLuaTableExpression ( expression . expression ) ;
4985- if ( expression . arguments . some ( argument => ts . isSpreadElement ( argument ) ) ) {
4986- throw TSTLErrors . ForbiddenLuaTableUseException ( "Arguments cannot be spread." , expression ) ;
4980+ protected validateLuaTableCall (
4981+ methodName : string ,
4982+ callArguments : ts . NodeArray < ts . Expression > ,
4983+ original : ts . Node
4984+ ) : void {
4985+ if ( callArguments . some ( argument => ts . isSpreadElement ( argument ) ) ) {
4986+ throw TSTLErrors . ForbiddenLuaTableUseException ( "Arguments cannot be spread." , original ) ;
49874987 }
49884988
49894989 switch ( methodName ) {
49904990 case "get" :
4991- if ( expression . arguments . length !== 1 ) {
4992- throw TSTLErrors . ForbiddenLuaTableUseException ( "One parameter is required for get()." , expression ) ;
4991+ if ( callArguments . length !== 1 ) {
4992+ throw TSTLErrors . ForbiddenLuaTableUseException ( "One parameter is required for get()." , original ) ;
49934993 }
49944994 break ;
49954995 case "set" :
4996- if ( expression . arguments . length !== 2 ) {
4997- throw TSTLErrors . ForbiddenLuaTableUseException (
4998- "Two parameters are required for set()." ,
4999- expression
5000- ) ;
4996+ if ( callArguments . length !== 2 ) {
4997+ throw TSTLErrors . ForbiddenLuaTableUseException ( "Two parameters are required for set()." , original ) ;
50014998 }
5002- if ( expression . parent . kind !== ts . SyntaxKind . ExpressionStatement ) {
5003- throw TSTLErrors . ForbiddenLuaTableSetExpression ( expression ) ;
4999+ if ( original . parent . kind !== ts . SyntaxKind . ExpressionStatement ) {
5000+ throw TSTLErrors . ForbiddenLuaTableSetExpression ( original ) ;
50045001 }
50055002 break ;
50065003 }
50075004 }
50085005
50095006 protected transformLuaTableExpressionAsExpressionStatement ( expression : ts . CallExpression ) : tstl . Statement {
50105007 const [ luaTable , methodName ] = this . parseLuaTableExpression ( expression . expression ) ;
5008+ this . validateLuaTableCall ( methodName , expression . arguments , expression ) ;
50115009 const signature = this . checker . getResolvedSignature ( expression ) ;
50125010 const params = this . transformArguments ( expression . arguments , signature ) ;
50135011
@@ -5031,6 +5029,7 @@ export class LuaTransformer {
50315029
50325030 protected transformLuaTableCallExpression ( expression : ts . CallExpression ) : tstl . Expression {
50335031 const [ luaTable , methodName ] = this . parseLuaTableExpression ( expression . expression ) ;
5032+ this . validateLuaTableCall ( methodName , expression . arguments , expression ) ;
50345033 const signature = this . checker . getResolvedSignature ( expression ) ;
50355034 const params = this . transformArguments ( expression . arguments , signature ) ;
50365035
0 commit comments