fix for loops
This commit is contained in:
@@ -1175,7 +1175,7 @@ ResultType(astNodePtr, ErrorMessage) parseForStatement(CometParser* parser) {
|
||||
|
||||
parserNextToken(parser);
|
||||
|
||||
bool isArrayLoop = !currentTokenIs(parser, CT_DOT_DOT);
|
||||
bool isArrayLoop = !peekTokenIs(parser, CT_DOT_DOT);
|
||||
if (isArrayLoop) { // we're looping over an array
|
||||
ResultType(astNodePtr, ErrorMessage) array = parseExpression(parser, PRECEDENCE_LOWEST);
|
||||
if (array.error) {
|
||||
|
||||
12
test.comet
12
test.comet
@@ -1,11 +1,11 @@
|
||||
import io
|
||||
|
||||
func main() -> int {
|
||||
int[3] array = [1, 2, 3]
|
||||
|
||||
for int x in array {
|
||||
io.println("%n", x)
|
||||
func main() -> void {
|
||||
for int v in [1,2,3,4,5] {
|
||||
io.println("value %n at index %n", v, i)
|
||||
}
|
||||
|
||||
return 0
|
||||
for int i in 0 .. 10 {
|
||||
io.println("%n", i)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user