Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in Ripper with $ special variables #1700

Closed
aselder opened this Issue May 15, 2014 · 5 comments

Comments

Projects
None yet
3 participants
@aselder
Copy link

aselder commented May 15, 2014

[~]$ ruby --version jruby 1.7.12 (1.9.3p392) 2014-04-15 643e292 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_51-b13 [darwin-x86_64]
[~]$ irb jruby-1.7.12 :001 > require 'ripper'
=> true
jruby-1.7.12 :002 > Ripper::SexpBuilder.new("$LOAD_PATH.unshift(File.dirname(FILE) + '/jars')").parse
=> [:program, [:stmts_add, [:stmts_new], [:method_add_arg, [:call, [:var_ref, [:@gvar, "$LOAD_PATH", [1, 0]]], :".", [:@ident, "unshift", [1, 11]]], [:arg_paren, [:args_add_block, [:args_add, [:args_new], [:binary, [:method_add_arg, [:call, [:var_ref, [:@const, "File", [1, 19]]], :".", [:@ident, "dirname", [1, 24]]], [:arg_paren, [:args_add_block, [:args_add, [:args_new], [:var_ref, [:@kw, "FILE", [1, 32]]]], false]]], :+, [:string_literal, [:string_add, [:string_content], [:@tstring_content, "/jars", [1, 45]]]]]], false]]]]]
jruby-1.7.12 :003 > Ripper::SexpBuilder.new("$:.unshift(File.dirname(FILE) + '/jars')").parse
Java::JavaLang::NullPointerException:
from org.jruby.ext.ripper.RipperParser.is_id_var(RipperParser.java:184)
from org.jruby.ext.ripper.Ripper19Parser$51.execute(Ripper19Parser.java:1795)
from org.jruby.ext.ripper.Ripper19Parser.yyparse(Ripper19Parser.java:1419)
from org.jruby.ext.ripper.Ripper19Parser.yyparse(Ripper19Parser.java:1310)
from org.jruby.ext.ripper.RipperParser.parse(RipperParser.java:78)
from org.jruby.ext.ripper.RubyRipper.parse(RubyRipper.java:306)
from org.jruby.ext.ripper.RubyRipper$INVOKER$i$0$0$parse.call(RubyRipper$INVOKER$i$0$0$parse.gen)
from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:306)
from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:136)
from org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60)
from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
from org.jruby.ast.RootNode.interpret(RootNode.java:129)
from org.jruby.evaluator.ASTInterpreter.INTERPRET_EVAL(ASTInterpreter.java:95)
from org.jruby.evaluator.ASTInterpreter.evalWithBinding(ASTInterpreter.java:184)
from org.jruby.RubyKernel.evalCommon(RubyKernel.java:1138)
from org.jruby.RubyKernel.eval19(RubyKernel.java:1101)
... 118 levels...
from org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
from org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
from org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)
from org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:198)
from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
from Users.aselder.$dot_rvm.rubies.jruby_minus_1_dot_7_dot_12.bin.irb.__file_(/Users/aselder/.rvm/rubies/jruby-1.7.12/bin/irb:13)
from Users.aselder.$_dot_rvm.rubies.jruby_minus_1_dot_7_dot_12.bin.irb.load(/Users/aselder/.rvm/rubies/jruby-1.7.12/bin/irb)
from org.jruby.Ruby.runScript(Ruby.java:811)
from org.jruby.Ruby.runScript(Ruby.java:804)
from org.jruby.Ruby.runNormally(Ruby.java:673)
from org.jruby.Ruby.runFromMain(Ruby.java:522)
from org.jruby.Main.doRunFromMain(Main.java:395)
from org.jruby.Main.internalRun(Main.java:290)
from org.jruby.Main.run(Main.java:217)
from org.jruby.Main.main(Main.java:197)
@aselder

This comment has been minimized.

Copy link
Author

aselder commented May 15, 2014

In fact this can be reduced to:

Ripper::SexpBuilder.new("$:").parse

Same error and stacktrace.

@aselder

This comment has been minimized.

Copy link
Author

aselder commented May 15, 2014

In fact, all the special variables blow up like this.

Tried $=, $!, $<, $$, $?, $~

@aselder aselder changed the title NPE in Ripper with $: variable NPE in Ripper with $ special variables May 15, 2014

@Gvar

This comment has been minimized.

Copy link

Gvar commented May 16, 2014

m@ybE 6ut 1 d't know

2014-05-16 2:04 GMT+03:00 Andrew Selder notifications@github.com:

In fact, all the special variable blow up like this.

Tried $=, $!, $<, $$, $?, $~


Reply to this email directly or view it on GitHubhttps://github.com//issues/1700#issuecomment-43275495
.

@aselder

This comment has been minimized.

Copy link
Author

aselder commented Sep 9, 2014

Still an issue in JRuby 1.7.15

This is break a lot of the static analysis tools (flog, flay, reek, etc) if you have any code using a special $-symbol variable.

@enebo enebo added this to the JRuby 1.7.16 milestone Sep 11, 2014

enebo added a commit that referenced this issue Sep 11, 2014

@enebo

This comment has been minimized.

Copy link
Member

enebo commented Sep 11, 2014

all special GVars and also tLabels (foo: 1) were broken because they were not being recorded as identifiers on their way out of the lexer.

@enebo enebo closed this Sep 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.