Description
I was debating making some unit tests for the for statement which covers oddities of it. for instance for(;;show_debug_message("second")){ show_debug_message("first") } will actually cycle and default the conditional statement to true. Secondly the note that an initializer isn't needed, and thirdly the incrementor should be a valid block statement. Though the downside with this is with gmrt it's possible these features are not intended behavior, and they are not syntax valid. So before making a PR I was hoping to get confirmation on which of these are expected syntax.
Much of this information was covered quite well by Katsaii in her Syntax Extension blog post.
Steps To The Task
Initializer:
- [Missing Initializer] Should be valid to be optional, this is only variable declaration and not a valid block statement
- [Single
var Initializer] This is the standard var i=0, and just a sanity check
- [Double
var Initializer] Confirmation var i=0, j=1; should work. (due note var i=0; var j=1 wont work even if wrapped in brackets)
Condition:
- [Missing Conditional] Should result in a default of
true every time
Incrementor:
- [Missing Incrementor] Incrementor statements are optional, and could simply be placed into the block statement
- [Incrementor Block Statement] The incrementor can accept a block statement such as
{ i += 2; j += 1 }.
Block Statement:
- [Empty Block Statement]
for(var i=0; i<j; i++){} valid syntax, however for(var i=0; i<j; i++); is crashing syntax reasonably
Description
I was debating making some unit tests for the
forstatement which covers oddities of it. for instancefor(;;show_debug_message("second")){ show_debug_message("first") }will actually cycle and default the conditional statement to true. Secondly the note that an initializer isn't needed, and thirdly the incrementor should be a valid block statement. Though the downside with this is with gmrt it's possible these features are not intended behavior, and they are not syntax valid. So before making a PR I was hoping to get confirmation on which of these are expected syntax.Much of this information was covered quite well by Katsaii in her Syntax Extension blog post.
Steps To The Task
Initializer:
varInitializer] This is the standardvar i=0, and just a sanity checkvarInitializer] Confirmationvar i=0, j=1;should work. (due notevar i=0; var j=1wont work even if wrapped in brackets)Condition:
trueevery timeIncrementor:
{ i += 2; j += 1 }.Block Statement:
for(var i=0; i<j; i++){}valid syntax, howeverfor(var i=0; i<j; i++);is crashing syntax reasonably