From 6672e9d1eea92af1aaef855fb96509065aa98ac1 Mon Sep 17 00:00:00 2001 From: Vincent Vanackere Date: Tue, 20 Jun 2017 18:59:46 +0200 Subject: [PATCH] Add missing idx to ast.ForStatement / ast.ForInStatement --- parser/statement.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/parser/statement.go b/parser/statement.go index da18829f..a8c7f997 100644 --- a/parser/statement.go +++ b/parser/statement.go @@ -2,6 +2,7 @@ package parser import ( "github.com/dop251/goja/ast" + "github.com/dop251/goja/file" "github.com/dop251/goja/token" ) @@ -356,7 +357,7 @@ func (self *_parser) parseIterationStatement() ast.Statement { return self.parseStatement() } -func (self *_parser) parseForIn(into ast.Expression) *ast.ForInStatement { +func (self *_parser) parseForIn(idx file.Idx, into ast.Expression) *ast.ForInStatement { // Already have consumed " in" @@ -364,13 +365,14 @@ func (self *_parser) parseForIn(into ast.Expression) *ast.ForInStatement { self.expect(token.RIGHT_PARENTHESIS) return &ast.ForInStatement{ + For: idx, Into: into, Source: source, Body: self.parseIterationStatement(), } } -func (self *_parser) parseFor(initializer ast.Expression) *ast.ForStatement { +func (self *_parser) parseFor(idx file.Idx, initializer ast.Expression) *ast.ForStatement { // Already have consumed " ;" @@ -387,6 +389,7 @@ func (self *_parser) parseFor(initializer ast.Expression) *ast.ForStatement { self.expect(token.RIGHT_PARENTHESIS) return &ast.ForStatement{ + For: idx, Initializer: initializer, Test: test, Update: update, @@ -435,11 +438,11 @@ func (self *_parser) parseForOrForInStatement() ast.Statement { self.nextStatement() return &ast.BadStatement{From: idx, To: self.idx} } - return self.parseForIn(left[0]) + return self.parseForIn(idx, left[0]) } self.expect(token.SEMICOLON) - return self.parseFor(&ast.SequenceExpression{Sequence: left}) + return self.parseFor(idx, &ast.SequenceExpression{Sequence: left}) } func (self *_parser) parseVariableStatement() *ast.VariableStatement {