-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
__FILE__ is not available in BEGIN section #4677
Comments
Confirmed. I believe @enebo is looking into this. |
9.1.14.0 still doesn't work. |
I'll have a poke at it. I'm guessing it's just some ordering that's not setting up the DATA section before entering into BEGIN chunks. |
Oops, not |
Looks like the problem here is that we're not preparing VM state properly for BEGIN. BEGIN and END both behave like |
Ahh I see the difference in JRuby between BEGIN and END. END is not implemented like |
Because BEGIN is a `for` block, when it executes we end up with a bogus scope between us and the toplevel. That scope does not have irScope set, which causes scope-requiring instructions like Filename (for __FILE__) to NPE. This fix helps guarantee all StaticScope reference at least their parent scope's irScope, rather than always starting out null.
I have pushed a fix that appears simple and safe. @enebo please review. |
bacedc5 Exclude a couple specs not supported on Windows 7a2c8be Disable Lint/AmbiguousBlockAssociation 677c103 Fix indentation 8eb3a31 Fix trailing whitespace b8d6e05 Suppress warnings around intended constant re-definition 0e31c13 Add RUBYOPT with extra whitespace command line spec 84e28fc Restrict the File.utime spec with large times to Linux 64-bit 47b9727 Add spec for File.utime with Time instances far in the future 421b858 Make sure to read the output of date in Kernel#open specs baf5d11 Add spec for IO#sysread 1884b1d Add specs that IO#{read,write}_nonblock sets the IO to nonblock mode 4d60f75 Improve Time#round spec 77ba816 Improve thread local specs 240afea Add FL_ABLE and FL_TEST specs c5bf527 Organize the Process.groups= spec ba8700e Move the Process.groups= example under the Process.groups= spec fb9c3a2 Fix DateTime.now spec 05b3ca1 Fix expectation in Dir#chroot spec 2ff8dc3 Add `rb_scan_args' specs for optional kwargs. 610a22f Give more margin for Mutex#sleep sleep time 3a7d4e1 Use a monotonic time to measure real-time intervals in Mutex#sleep spec b6e9294 Specs for string issues found. Yaml test currently tagged. de9ecda Implement rb_absint_singlebit_p and add spec 250e29a Only require fixtures needing refinements in the examples that need it 6b05eed Avoid loading a fixture using #refine while loading c7c888a Fix IO#each spec 4cda555 Add spec for Time.{utc,gm} with small fractional usec. 12ab462 Add spec for tiny Mutex#sleep times. 6b14dca Spec for __FILE__ in BEGIN. See #4677. 3a9d651 Add spec for looped delegation of a block containing a break. d04818f Added specs for IO#each(sep,limit) (#4833) df0a78f Add spec for Time#to_datetime 2e1c77c Add a spec for DateTime#to_time 7e69e0a Basic constant assign specs for &&= 9089561 Make BigDecimal::limit work for subtraction and division. Fix #1615. 3041df8 Adapt sprintf/format specs to handle the 2.5 behavior for sprintf("%") 4c29047 Restore the return in class spec and specify the old and new behaviors 1da2fca Put a problematic refine spec in quarantine 7db8544 spec/ruby/optional/capi/constants_spec.rb: Data is deprecated now 85f85b4 * append newline at EOF. ec75aa8 Add specs for concurrent Module#autoload 0fcde61 Reorganize Module#autoload to have similar specs next to each other eef31f7 parse.y: no return in class 7f8a8b7 load from relative path to __FILE__ 85562a8 Clarify what is written and read in IO#popen spec cc7bfbd Fix spec which can fail if the pipe is closed before flushing in the subprocess 9f8d3d0 Some methods of Module are now public f2f23ad Fix File#printf specs running on Windows bcc750f Suppress Rubocop warnings bc797f8 Code review. Share test cases for b and B, g and G, e and E, d, i and u formats 91ab65a Code review. Minor issues e1d646d Remove excessive specs b8bbe86 Adopt already existed test cases 5a30b08 Include shared example for StringIO#printf 8de650e Include shared example for String#% 19ce86a Include shared example for File#printf b77658e Include shared example for Kernel#sprintf 1ddb415 Include shared example for Kernel#printf 764b78b Shared example: Add reference by name acc3bdf Shared example: Add precision b001a62 Shared example: Add width 1800767 Shared example: Add flags f148cc7 Shared example: Add types 760a41e Add specs for Array#append [Feature #12746] 8bde28c Move Array#push specs to shared/ bc769a8 Remove superfluous spec e32f79f Add specs for Array#prepend [Feature #12746] ff2eb10 Move Array#unshift specs to shared/ e7ac1ca Test that the rescue in method arguments fails when not between parens a7770da Update line number 43fe574 Remove old guard e7598e6 Remove guards for old versions f3599a7 Clarify which part should be undefined in defined? specs 76df3f7 Avoid defining top-level constants in TracePoint specs e84c928 #513 Add TracePoint specs (#518) 7d76b72 Workaround Travis CI issue by hardcoding localhost 2025413 fix trailing space f179d05 Avoid plain "should raise_error" by specifying an expected error class 6a2034c Require spec_helper should be first 2ab4d54 Pick up sibling mspec when running a spec with 'ruby' directly 214791f Fix File::Stat#blocks spec to allow zero 11a0cf2 Fix platform dependent specs for File.empty? 663d8eb Ignore the libruby check if it cannot be found 7069967 Make sure to compile each extension only once in ruby/spec c051e55 Use ENV['RUBY_EXE'] as RbConfig.ruby might be incorrect 6b65a12 * append newline at EOF. git-subtree-dir: spec/ruby git-subtree-split: bacedc542c85b825f01d2698d037fad8e1c012a4
bacedc5 Exclude a couple specs not supported on Windows 7a2c8be Disable Lint/AmbiguousBlockAssociation 677c103 Fix indentation 8eb3a31 Fix trailing whitespace b8d6e05 Suppress warnings around intended constant re-definition 0e31c13 Add RUBYOPT with extra whitespace command line spec 84e28fc Restrict the File.utime spec with large times to Linux 64-bit 47b9727 Add spec for File.utime with Time instances far in the future 421b858 Make sure to read the output of date in Kernel#open specs baf5d11 Add spec for IO#sysread 1884b1d Add specs that IO#{read,write}_nonblock sets the IO to nonblock mode 4d60f75 Improve Time#round spec 77ba816 Improve thread local specs 240afea Add FL_ABLE and FL_TEST specs c5bf527 Organize the Process.groups= spec ba8700e Move the Process.groups= example under the Process.groups= spec fb9c3a2 Fix DateTime.now spec 05b3ca1 Fix expectation in Dir#chroot spec 2ff8dc3 Add `rb_scan_args' specs for optional kwargs. 610a22f Give more margin for Mutex#sleep sleep time 3a7d4e1 Use a monotonic time to measure real-time intervals in Mutex#sleep spec b6e9294 Specs for string issues found. Yaml test currently tagged. de9ecda Implement rb_absint_singlebit_p and add spec 250e29a Only require fixtures needing refinements in the examples that need it 6b05eed Avoid loading a fixture using #refine while loading c7c888a Fix IO#each spec 4cda555 Add spec for Time.{utc,gm} with small fractional usec. 12ab462 Add spec for tiny Mutex#sleep times. 6b14dca Spec for __FILE__ in BEGIN. See jruby/jruby#4677. 3a9d651 Add spec for looped delegation of a block containing a break. d04818f Added specs for IO#each(sep,limit) (jruby/jruby#4833) df0a78f Add spec for Time#to_datetime 2e1c77c Add a spec for DateTime#to_time 7e69e0a Basic constant assign specs for &&= 9089561 Make BigDecimal::limit work for subtraction and division. Fix jruby/jruby#1615. 3041df8 Adapt sprintf/format specs to handle the 2.5 behavior for sprintf("%") 4c29047 Restore the return in class spec and specify the old and new behaviors 1da2fca Put a problematic refine spec in quarantine 7db8544 spec/ruby/optional/capi/constants_spec.rb: Data is deprecated now 85f85b4 * append newline at EOF. ec75aa8 Add specs for concurrent Module#autoload 0fcde61 Reorganize Module#autoload to have similar specs next to each other eef31f7 parse.y: no return in class 7f8a8b7 load from relative path to __FILE__ 85562a8 Clarify what is written and read in IO#popen spec cc7bfbd Fix spec which can fail if the pipe is closed before flushing in the subprocess 9f8d3d0 Some methods of Module are now public f2f23ad Fix File#printf specs running on Windows bcc750f Suppress Rubocop warnings bc797f8 Code review. Share test cases for b and B, g and G, e and E, d, i and u formats 91ab65a Code review. Minor issues e1d646d Remove excessive specs b8bbe86 Adopt already existed test cases 5a30b08 Include shared example for StringIO#printf 8de650e Include shared example for String#% 19ce86a Include shared example for File#printf b77658e Include shared example for Kernel#sprintf 1ddb415 Include shared example for Kernel#printf 764b78b Shared example: Add reference by name acc3bdf Shared example: Add precision b001a62 Shared example: Add width 1800767 Shared example: Add flags f148cc7 Shared example: Add types 760a41e Add specs for Array#append [Feature #12746] 8bde28c Move Array#push specs to shared/ bc769a8 Remove superfluous spec e32f79f Add specs for Array#prepend [Feature #12746] ff2eb10 Move Array#unshift specs to shared/ e7ac1ca Test that the rescue in method arguments fails when not between parens a7770da Update line number 43fe574 Remove old guard e7598e6 Remove guards for old versions f3599a7 Clarify which part should be undefined in defined? specs 76df3f7 Avoid defining top-level constants in TracePoint specs e84c928 #513 Add TracePoint specs (#518) 7d76b72 Workaround Travis CI issue by hardcoding localhost 2025413 fix trailing space f179d05 Avoid plain "should raise_error" by specifying an expected error class 6a2034c Require spec_helper should be first 2ab4d54 Pick up sibling mspec when running a spec with 'ruby' directly 214791f Fix File::Stat#blocks spec to allow zero 11a0cf2 Fix platform dependent specs for File.empty? git-subtree-dir: spec/ruby git-subtree-split: bacedc542c85b825f01d2698d037fad8e1c012a4
blah.rb
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
Actual Behavior
The text was updated successfully, but these errors were encountered: