@@ -798,10 +798,19 @@ export class LuaTranspiler {
798798 result = `${ lhs } <=${ rhs } ` ;
799799 break ;
800800 case ts . SyntaxKind . EqualsToken :
801+ let assignmentValue = rhs ;
802+ // If the right-hand side of the equation is a tuple return method
803+ // and the left-hand side is not a destructing statement, wrap the
804+ // rhs in { }.
805+ if ( ts . isIdentifier ( node . left ) && tsHelper . isTupleReturnCall ( node . right , this . checker ) ) {
806+ assignmentValue = `{ ${ rhs } }` ;
807+ }
808+
801809 if ( tsHelper . hasSetAccessor ( node . left , this . checker ) ) {
802- return this . transpileSetAccessor ( node . left as ts . PropertyAccessExpression , rhs ) ;
810+ return this . transpileSetAccessor ( node . left as ts . PropertyAccessExpression , assignmentValue ) ;
803811 }
804- result = `${ lhs } =${ rhs } ` ;
812+
813+ result = `${ lhs } =${ assignmentValue } ` ;
805814 break ;
806815 case ts . SyntaxKind . EqualsEqualsToken :
807816 case ts . SyntaxKind . EqualsEqualsEqualsToken :
@@ -1176,7 +1185,15 @@ export class LuaTranspiler {
11761185 const identifier = node . name ;
11771186 if ( node . initializer ) {
11781187 const value = this . transpileExpression ( node . initializer ) ;
1179- return `local ${ identifier . escapedText } = ${ value } \n` ;
1188+
1189+ // If the right-hand side of the equation is a tuple return method
1190+ // and the left-hand side is not a destructing statement, wrap the
1191+ // rhs in { }.
1192+ if ( tsHelper . isTupleReturnCall ( node . initializer , this . checker ) ) {
1193+ return `local ${ identifier . escapedText } = { ${ value } }\n` ;
1194+ } else {
1195+ return `local ${ identifier . escapedText } = ${ value } \n` ;
1196+ }
11801197 } else {
11811198 return `local ${ identifier . escapedText } = nil\n` ;
11821199 }
@@ -1194,10 +1211,7 @@ export class LuaTranspiler {
11941211 ) . escapedText ) . join ( "," ) ;
11951212
11961213 // Don't unpack TupleReturn decorated functions
1197- if ( ts . isCallExpression ( node . initializer )
1198- && tsHelper . isTupleReturnFunction ( this . checker . getTypeAtLocation ( node . initializer . expression ) ,
1199- this . checker )
1200- ) {
1214+ if ( tsHelper . isTupleReturnCall ( node . initializer , this . checker ) ) {
12011215 return `local ${ vars } =${ value } \n` ;
12021216 } else {
12031217 return `local ${ vars } =table.unpack(${ value } )\n` ;
0 commit comments