JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-5792

Eval error for hashes containing symbols ending with an equals sign

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.5.1, JRuby 1.5.2, JRuby 1.5.3, JRuby 1.5.4, JRuby 1.5.5, JRuby 1.5.6, JRuby 1.6RC1, JRuby 1.6RC2, JRuby 1.6RC3, JRuby 1.6, JRuby 1.6.1
    • Fix Version/s: JRuby 1.6.6, JRuby 1.7.0.pre1
    • Component/s: Parser
    • Labels:
      None
    • Environment:
      tested on Windows, Linux and Android
    • Number of attachments :
      0

      Description

      Ruby allows equal signs in symbols. Inspecting one of these produces a slightly awkward string:

      {:a= => 1}.inspect   # => "{:a==>1}"
      

      evaling this string in MRI works:

      eval({:a= => 1}.inspect)[:a=] # => 1
      

      If I do the same in JRuby:

      eval({:a= => 1}.inspect)  # => I get the following error:
      
      SyntaxError: (eval):1: syntax error, unexpected tGT
      
      {:a==>1}
           ^
              from (eval):1
      

      The easiest workaround is to assist the parser:

      eval({:a= => 1}.inspect.gsub('==>', '= =>'))[:a=]
      

        Activity

        Hide
        Hiro Asari added a comment -

        This esoteric corner case of the Ruby grammar was fixed on master (8cc3547) and on 1.6 (e36fd2f).

        Thank you for reporting. I will work on RubySpec.

        Show
        Hiro Asari added a comment - This esoteric corner case of the Ruby grammar was fixed on master (8cc3547) and on 1.6 (e36fd2f). Thank you for reporting. I will work on RubySpec.
        Hide
        Hiro Asari added a comment -
        Show
        Hiro Asari added a comment - FYI: https://github.com/rubyspec/rubyspec/pull/107

          People

          • Assignee:
            Hiro Asari
            Reporter:
            Scott Moyer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: