File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed
Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -312,7 +312,8 @@ var LuaTranspiler = /** @class */ (function () {
312312 var expression = this . transpileExpression ( node . expression , true ) ;
313313 var clauses = node . caseBlock . clauses ;
314314 var result = this . indent + "-------Switch statement start-------\n" ;
315- var jumpTableName = "____switch" + ++ this . genVarCounter ;
315+ var jumpTableName = "____switch" + this . genVarCounter ;
316+ this . genVarCounter ++ ;
316317 result += this . indent + ( "local " + jumpTableName + " = {\n" ) ;
317318 this . pushIndent ( ) ;
318319 // If statement to go to right entry label
@@ -337,7 +338,8 @@ var LuaTranspiler = /** @class */ (function () {
337338 while ( i < clauses . length
338339 && ts . isCaseClause ( nextClause )
339340 && nextClause . statements . length === 0 ) {
340- nextClause = clauses [ ++ i ] ;
341+ i ++ ;
342+ nextClause = clauses [ i ] ;
341343 }
342344 if ( i !== index && nextClause ) {
343345 if ( ts . isCaseClause ( nextClause ) ) {
Original file line number Diff line number Diff line change @@ -347,7 +347,8 @@ export class LuaTranspiler {
347347
348348 let result = this . indent + "-------Switch statement start-------\n" ;
349349
350- let jumpTableName = "____switch" + ++ this . genVarCounter
350+ let jumpTableName = "____switch" + this . genVarCounter ;
351+ this . genVarCounter ++ ;
351352
352353 result += this . indent + `local ${ jumpTableName } = {\n` ;
353354
@@ -378,7 +379,8 @@ export class LuaTranspiler {
378379 && ts . isCaseClause ( nextClause )
379380 && nextClause . statements . length === 0
380381 ) {
381- nextClause = clauses [ ++ i ] ;
382+ i ++ ;
383+ nextClause = clauses [ i ] ;
382384 }
383385
384386 if ( i !== index && nextClause ) {
Original file line number Diff line number Diff line change @@ -173,7 +173,8 @@ export class LuaConditionalsTests {
173173 @TestCase ( 2 , 4 )
174174 @TestCase ( 3 , 4 )
175175 @TestCase ( 4 , 4 )
176- @TestCase ( 5 , - 2 )
176+ @TestCase ( 5 , 15 )
177+ @TestCase ( 7 , - 2 )
177178 @Test ( "switchfallthrough" )
178179 public switchfallthrough ( inp : number , expected : number ) {
179180 /// Transpile
@@ -194,6 +195,11 @@ export class LuaConditionalsTests {
194195 break;
195196 case 5:
196197 result = 5;
198+ case 6:
199+ result += 10;
200+ break;
201+ case 7:
202+ result = 7;
197203 default:
198204 result = -2;
199205 break;
You can’t perform that action at this time.
0 commit comments