#17 new
Rick

syntax error - versions 2.0.4 and 2.0.5

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

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

Comments and changes to this ticket

  • Rick

    Rick March 26th, 2009 @ 03:40 PM

    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

    Rick March 26th, 2009 @ 03:59 PM

    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

    Rick March 26th, 2009 @ 04:23 PM

    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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Library for adding state machines to Ruby classes. Includes persistence layers for things like ActiveRecord. Formerly known as acts_as_state_machine.

People watching this ticket

Pages