Skip to content

Commit

Permalink
Fix return statement range (AssemblyScript#880)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO authored and Willem Wyndham committed Oct 13, 2019
1 parent e34b4ee commit ff8b51e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ export class Parser extends DiagnosticEmitter {

// at 'return': Expression | (';' | '}' | ...'\n')

var startPos = tn.tokenPos;
var expr: Expression | null = null;
if (
tn.peek(true) != Token.SEMICOLON &&
Expand All @@ -1020,7 +1021,7 @@ export class Parser extends DiagnosticEmitter {
if (!(expr = this.parseExpression(tn))) return null;
}

var ret = Node.createReturnStatement(expr, tn.range());
var ret = Node.createReturnStatement(expr, tn.range(startPos, tn.pos));
tn.skip(Token.SEMICOLON);
return ret;
}
Expand Down

0 comments on commit ff8b51e

Please sign in to comment.