Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre2
    • Fix Version/s: JRuby 1.7.0.RC1
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      class MyClass
        attr_accessor :pred?
      end
      

      The above code runs with no error in JRuby 1.7.0-preview2 (and 1.6.7).

      In MRI (1.9.2p290), it fails with the exception

      in `attr_accessor': invalid attribute name `pred?' (NameError)
      

      It seems Ruby 1.8.2 had the same behavior as JRuby: http://www.ruby-forum.com/topic/89770

      See also related topic here: http://www.ruby-forum.com/topic/135195

        Activity

        Hide
        Charles Oliver Nutter added a comment -
        commit bef3b7040c09e8d85f7042cf7360d55dbd369ed4
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Mon Aug 27 11:36:21 2012 -0500
        
            Fix JRUBY-6865
            
            JRuby allows invalid attr_accessor (MRI raises exception)
            
            Our test for local variable names (which applies in both JRuby and
            MRI to attr names) did not check for trailing ?. I added that one
            case.
            
            Note that in MRI all of this passes through ID parsing, which has
            logic for checking the type of ID I did not attempt to sort out.
            There are other cases we probably let through that MRI does not.
            
            Test submitted to MRI via https://github.com/ruby/ruby/pull/171
        
        :100644 100644 a236fac... ad2154a... M	src/org/jruby/RubyModule.java
        :100644 100644 88b83c7... 884493d... M	src/org/jruby/util/IdUtil.java
        
        Show
        Charles Oliver Nutter added a comment - commit bef3b7040c09e8d85f7042cf7360d55dbd369ed4 Author: Charles Oliver Nutter <headius@headius.com> Date: Mon Aug 27 11:36:21 2012 -0500 Fix JRUBY-6865 JRuby allows invalid attr_accessor (MRI raises exception) Our test for local variable names (which applies in both JRuby and MRI to attr names) did not check for trailing ?. I added that one case. Note that in MRI all of this passes through ID parsing, which has logic for checking the type of ID I did not attempt to sort out. There are other cases we probably let through that MRI does not. Test submitted to MRI via https://github.com/ruby/ruby/pull/171 :100644 100644 a236fac... ad2154a... M src/org/jruby/RubyModule.java :100644 100644 88b83c7... 884493d... M src/org/jruby/util/IdUtil.java

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Patrick Mahoney
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: