Bug - Fixed for/foreach do not respect reserved keywords.

heeheehee

Developer
Staff member
Example:
Code:
> ash boolean[int] a = $ints[1, 2]; foreach record in a { print(record);}

1
2

> ash for int from 1 to 10{ print(int);}

1
2
3
4
5
6
7
8
9
10
Returned: void
 
Last edited:
Didn't think about the for loop.

Revision 11386 does foreach, revision 11387 does for.

would it make more sense for Parser.ForEachLoop to create a new frame
If by "frame", you mean "scope", it does that. It gets the list of key variable names and then creates a scope with those variables as local variables within the scope.

Code:
		// Parse the scope with the list of keyVars
		Scope scope = this.parseLoopScope( functionType, varList, parentScope );
So, what exactly are you asking?
 
All right, thanks!

That statement was the result of me changing my mind halfway through an edit and then forgetting to remove said part of the edit. And then I looked at the code and realized that this was already being done.

What I really should've asked was whether or not it made more sense to reuse Parser.parseVariables inside the parsing of said loops (as that was the approach I was considering).
 
Last edited:
What I really should've asked was whether or not it made more sense to reuse Parser.parseVariables inside the parsing of said loops (as that was the approach I was considering).
No. That method will parse typed variables and initialize them. For example, "int foo = 2". It's used for getting variable declarations/definitions inside a scope, but for and foreach want nothing but variable names; type is implicit and the value is set each time through the loop.
 
I see. For some reason I thought that was used inside parseFunction, but even if it were, that still wouldn't be useful, since the variable type would still need to be specified.
 
Back
Top