diff --git a/src/files/BrsFile.spec.ts b/src/files/BrsFile.spec.ts index d089a59e8..a8ac24165 100644 --- a/src/files/BrsFile.spec.ts +++ b/src/files/BrsFile.spec.ts @@ -2604,6 +2604,19 @@ describe('BrsFile', () => { `); }); + it('handles else block with a leading comment', () => { + testTranspile(` + sub main() + if true then + print "if" + else + ' leading comment + print "else" + end if + end sub + `); + }); + it('works for function parameters', () => { testTranspile(` function DoSomething(name, age as integer, text as string) diff --git a/src/parser/Statement.ts b/src/parser/Statement.ts index 0f6f63f65..7972cfb90 100644 --- a/src/parser/Statement.ts +++ b/src/parser/Statement.ts @@ -454,7 +454,7 @@ export class IfStatement extends Statement { } else { //else body - state.lineage.unshift(this.elseBranch); + state.lineage.unshift(this.tokens.else); let body = this.elseBranch.transpile(state); state.lineage.shift();