syntax error - versions 2.0.4 and 2.0.5
-
Rick
The trailing colon in the when expression is seems to be allowed in Ruby 1.8.7 but not required. However, Ruby 1.9.1p0 will not allow the trailing colon.
I don't have the source for earlier versions of ruby but parse.y for 1.9.1p0 doesn't have a provision for a trailing colon so it's being glommed on to the preceeding symbol.
-
Rick
So here's another possible fix:
when String, Symbol:
when String, Symbol :
This change passes muster with 1.9.1p0. The rule seems to be "then | :" is optional when associated code begins on a new line. What I'm still unclear about is why the older ruby parsed the colon as a separate token rather than part of the preceding symbol. I'm guessing there was a precedence change in there somewhere.
-
Rick
That previous possible fix does not work. I must be losing the connection between my eyes and my brain.
A colon is no longer allowed in association with the when expression. The relevant rules from parse.y are:
@@@case_body : keyword_when args then
compstmt cases { /*%%%*/ $$ = NEW_WHEN($2, $4, $5); /*% $$ = dispatch3(when, $2, $4, escape_Qundef($5)); %*/ } ;then : term
/*%c%*/ /*%c { $$ = Qnil; } %*/ | keyword_then | term keyword_then /*%c%*/ /*%c { $$ = $2; } %*/ ;The definition of then is what changed. Here's the relevant snip from 1.8.7 parse.y: @@@then : term | ':' | kTHEN | term kTHEN ;
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.