Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: efbf2af718a2
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2565797ae060
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 20, 2017

  1. Use parent scope's IRSCope if available. Fixes #4677.

    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.
    headius committed Nov 20, 2017
    Copy the full SHA
    cabb82f View commit details
  2. Copy the full SHA
    2565797 View commit details
Showing with 5 additions and 1 deletion.
  1. +1 −1 core/src/main/java/org/jruby/parser/StaticScope.java
  2. +4 −0 spec/ruby/language/BEGIN_spec.rb
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/parser/StaticScope.java
Original file line number Diff line number Diff line change
@@ -160,7 +160,7 @@ protected StaticScope(Type type, StaticScope enclosingScope, String[] names, int
this.variableNames = names;
this.variableNamesLength = names.length;
this.type = type;
this.irScope = null;
this.irScope = enclosingScope == null ? null : enclosingScope.irScope;
this.isBlockOrEval = (type != Type.LOCAL);
this.isArgumentScope = !isBlockOrEval;
this.firstKeywordIndex = firstKeywordIndex;
4 changes: 4 additions & 0 deletions spec/ruby/language/BEGIN_spec.rb
Original file line number Diff line number Diff line change
@@ -29,4 +29,8 @@

ScratchPad.recorded.should == ['foo', 'bar']
end

it "returns the top-level script's filename for __FILE__" do
ruby_exe(fixture(__FILE__, "begin_file.rb")).chomp.should =~ /begin_file\.rb$/
end
end