ClassCastException: org.jruby.ast.NthRefNode w/match variables used as #$1 in 
here document in string substitution
------------------------------------------------------------------------------------------------------------------

                 Key: JRUBY-1242
                 URL: http://jira.codehaus.org/browse/JRUBY-1242
             Project: JRuby
          Issue Type: Bug
          Components: Parser
    Affects Versions: JRuby 1.x
         Environment: jruby / trunk / linux
            Reporter: skaar


The last of these examples will throw an exception while parsing - works with 
MRI, breaks with JRuby:

{code}
$global = "global value"
puts <<EOT
#$global
EOT

# works with JRuby & MRI
value = "some value"
value.sub!(/\A(\S*)(.*?)(\S*)\Z/m) do |m|
  <<EOT
#$global
EOT
end
puts value  # => "global value"

# works with JRuby & MRI
value = "some value"
value.sub!(/\A(\S*)(.*?)(\S*)\Z/m) do |m|
  <<EOT
#{$1} other #{$3}
EOT
end
puts value  # => "some other value"

# breaks with JRuby
value = "some value"
value.sub!(/\A(\S*)(.*?)(\S*)\Z/m) do |m|
  <<EOT
#$1 other #$3
EOT
end
puts value
{code}

Exception:
{code}
$ jruby b.rb 
Exception in thread "main" java.lang.ClassCastException: 
org.jruby.ast.NthRefNode
        at 
org.jruby.parser.DefaultRubyParser.yyparse(DefaultRubyParser.java:2683)
        at 
org.jruby.parser.DefaultRubyParser.yyparse(DefaultRubyParser.java:836)
        at org.jruby.parser.DefaultRubyParser.parse(DefaultRubyParser.java:3303)
        at org.jruby.parser.Parser.parse(Parser.java:101)
        at org.jruby.Ruby.parseFile(Ruby.java:1077)
        at org.jruby.Main.getParsedScript(Main.java:243)
        at org.jruby.Main.runInterpreter(Main.java:223)
        at org.jruby.Main.runInterpreter(Main.java:176)
        at org.jruby.Main.run(Main.java:121)
        at org.jruby.Main.main(Main.java:96)
{code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to