Skip to content

Unhandled Java exception in Ripper on inline comments #4792

@zverok

Description

@zverok

Environment

$jruby -v
jruby 9.1.13.0 (2.3.3) 2017-09-06 8e1c115 OpenJDK 64-Bit Server VM 25.131-b11 on 1.8.0_131-8u131-b11-0ubuntu1.16.10.2-b11 +jit [linux-x86_64]
$ uname -a
Linux platypus 4.8.0-59-generic #64-Ubuntu SMP Thu Jun 29 19:38:34 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Test file (verbatim):

%w[-1]
  .map(&:to_i) # FIXME
  .select(&:positive?)

Test script:

require 'ripper'
Ripper.sexp(File.read('test.rb'), 'test.rb')

Expected Behavior

No error.

Actual Behavior

Unhandled Java exception: java.lang.NullPointerException
java.lang.NullPointerException: null
  dispatchDelayedToken at org/jruby/ext/ripper/RipperLexer.java:767
                 yylex at org/jruby/ext/ripper/RipperLexer.java:1077
             nextToken at org/jruby/ext/ripper/RipperLexer.java:360
               yyparse at org/jruby/ext/ripper/RipperParser.java:1520
               yyparse at org/jruby/ext/ripper/RipperParser.java:1471
                 parse at org/jruby/ext/ripper/RipperParserBase.java:78
                 parse at org/jruby/ext/ripper/RubyRipper.java:327
                  call at org/jruby/ext/ripper/RubyRipper$INVOKER$i$0$0$parse.gen:-1
          cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:318
                  call at org/jruby/runtime/callsite/CachingCallSite.java:131
           processCall at org/jruby/ir/interpreter/InterpreterEngine.java:339
             interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:73
             interpret at org/jruby/ir/interpreter/InterpreterEngine.java:89
      INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:214
                  call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:200
                  call at org/jruby/internal/runtime/methods/DynamicMethod.java:208
          cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:358
                  call at org/jruby/runtime/callsite/CachingCallSite.java:195
     invokeOther8:sexp at rip.rb:5
                <main> at rip.rb:5
   invokeWithArguments at java/lang/invoke/MethodHandle.java:627
                  load at org/jruby/ir/Compiler.java:95
             runScript at org/jruby/Ruby.java:828
           runNormally at org/jruby/Ruby.java:747
           runNormally at org/jruby/Ruby.java:765
           runFromMain at org/jruby/Ruby.java:578
         doRunFromMain at org/jruby/Main.java:417
           internalRun at org/jruby/Main.java:305
                   run at org/jruby/Main.java:232
                  main at org/jruby/Main.java:204

The exception is gone when I remove # FIXME inline comment.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions