Skip to content

Commit

Permalink
Foreach improvements (#92)
Browse files Browse the repository at this point in the history
* Fix error test

Signed-off-by: Flipez <code@brauser.io>

* Add more specific error

Signed-off-by: Flipez <code@brauser.io>
  • Loading branch information
Flipez authored Jul 3, 2022
1 parent 022fe97 commit 4d453f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/misc/foreach-error.rl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
foreach i, v in [1,2,3] {
foreach i, v in [1,2,3]
v.reverse()
puts(v)
}
end
5 changes: 5 additions & 0 deletions parser/foreach.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func (p *Parser) parseForEach() ast.Expression {
}

if !p.expectPeek(token.IN) {
p.errors = append(p.errors, fmt.Sprintf(
"%d:%d: expected `in` after foreach arguments, got %v",
p.peekToken.LineNumber,
p.peekToken.LinePosition,
p.peekToken))
return nil
}
p.nextToken()
Expand Down

1 comment on commit 4d453f4

@vercel
Copy link

@vercel vercel bot commented on 4d453f4 Jul 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.