Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

syntax error - versions 2.0.4 and 2.0.5

#17

From: rubyist-aasm-2.0.[45]/lib/event.rb

  def execute_success_callback(obj)
    case success
    when String, Symbol:
      obj.send(success)
    when Array:
      success.each { |meth| obj.send(meth) }
    when Proc:
      success.call(obj)
    end
  end

"when String, Symbol:" should be "when String, Symbol" "when Array:" should be "when Array" "when Proc:" should be "when Proc"

Runtime environment:

Ruby version 1.9.1 (powerpc-darwin9.6.0) RubyGems version 1.3.1 Rack version 1.0 bundled Rails version 2.3.2 Active Record version 2.3.2 Action Pack version 2.3.2 Active Resource version 2.3.2 Action Mailer version 2.3.2 Active Support version 2.3.2 Application root /Users/rick/auth_auth Environment development Database adapter postgresql Database schema version 20090326052638

Reported by Rick · March 26th, 2009 @ 03:09 PM

State: new
Milestone: none
Assigned to: Scott Barron Scott Barron

Activity

  1. Rick
    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.

    March 26th, 2009 @ 03:40 PM

  2. Rick
    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.

    March 26th, 2009 @ 03:59 PM

  3. Rick
    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
    		;
    
    

    March 26th, 2009 @ 04:23 PM

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.