Skip to content

__FILE__ is not available in BEGIN section #4677

@jakago

Description

@jakago

blah.rb

BEGIN {
  p __FILE__
}

Environment

ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-darwin15]

jruby 9.1.9.0 (2.3.3) 2017-05-15 28aa830 Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [darwin-x86_64]

Darwin mac-mini.local 15.6.0 Darwin Kernel Version 15.6.0: Mon Jan 9 23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64 x86_64

Expected Behavior

$ ruby -v
ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-darwin15]
$ ruby blah.rb
"blah.rb"

Actual Behavior

$ jruby -v
jruby 9.1.9.0 (2.3.3) 2017-05-15 28aa830 Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [darwin-x86_64]
$ jruby blah.rb
java.lang.NullPointerException: null
         retrieve at org/jruby/ir/operands/Filename.java:50
       retrieveOp at org/jruby/ir/interpreter/InterpreterEngine.java:591
   processOtherOp at org/jruby/ir/interpreter/StartupInterpreterEngine.java:148
        interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:111
  INTERPRET_BLOCK at org/jruby/ir/interpreter/Interpreter.java:132
  commonYieldPath at org/jruby/runtime/MixedModeIRBlockBody.java:148
          doYield at org/jruby/runtime/IRBlockBody.java:186
            yield at org/jruby/runtime/BlockBody.java:116
            yield at org/jruby/runtime/Block.java:165
   runBeginBlocks at org/jruby/ir/interpreter/Interpreter.java:57
          execute at org/jruby/ir/interpreter/Interpreter.java:98
          execute at org/jruby/ir/interpreter/Interpreter.java:35
          execute at org/jruby/ir/IRTranslator.java:42
   runInterpreter at org/jruby/Ruby.java:844
   runInterpreter at org/jruby/Ruby.java:848
      runNormally at org/jruby/Ruby.java:751
      runNormally at org/jruby/Ruby.java:764
      runFromMain at org/jruby/Ruby.java:577
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions