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: 15da92141aa1
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8b606bfd8c35
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on May 17, 2016

  1. Copy the full SHA
    9716924 View commit details
  2. Copy the full SHA
    1b6f75d View commit details
  3. Copy the full SHA
    8b606bf View commit details
Showing with 9 additions and 16 deletions.
  1. +1 −0 spec/ruby/language/defined_spec.rb
  2. +1 −1 tool/jt.rb
  3. +7 −15 truffle/src/main/java/org/jruby/truffle/language/constants/ReadLiteralConstantNode.java
1 change: 1 addition & 0 deletions spec/ruby/language/defined_spec.rb
Original file line number Diff line number Diff line change
@@ -764,6 +764,7 @@
end

it "returns nil when a constant is scoped to an undefined constant" do
Object.should_not_receive(:const_missing)
defined?(Undefined::Object).should be_nil
end

2 changes: 1 addition & 1 deletion tool/jt.rb
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ module Utilities

def self.truffle_version
File.foreach("#{JRUBY_DIR}/truffle/pom.rb") do |line|
if /'truffle\.version' => '(\d+\.\d+(?:-SNAPSHOT)?)'/ =~ line
if /'truffle\.version' => '(\d+\.\d+|\h+-SNAPSHOT)'/ =~ line
break $1
end
end
Original file line number Diff line number Diff line change
@@ -37,24 +37,16 @@ public Object execute(VirtualFrame frame) {

@Override
public Object isDefined(VirtualFrame frame) {
final RubyContext context = getContext();
final String name = (String) readConstantNode.nameNode.execute(frame);

final Object module;
try {
module = readConstantNode.moduleNode.execute(frame);
} catch (RaiseException e) {
/* If we are looking up a constant in a constant that is itself undefined, we return Nil
* rather than raising the error. Eg.. defined?(Defined::Undefined1::Undefined2).
*
* We should maybe try to see if receiver.isDefined() but we also need its value if it is,
* and we do not want to execute receiver twice. */
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getException()) == context.getCoreLibrary().getNameErrorClass()) {
return nil();
}
throw e;
// TODO (eregon, 17 May 2016): We execute moduleNode twice here but we both want to make sure the LHS is defined and get the result value.
// Possible solution: have a isDefinedAndReturnValue()?
Object isModuleDefined = readConstantNode.moduleNode.isDefined(frame);
if (isModuleDefined == nil()) {
return nil();
}

final Object module = readConstantNode.moduleNode.execute(frame);
if (!RubyGuards.isRubyModule(module)) {
return nil();
}
@@ -63,7 +55,7 @@ public Object isDefined(VirtualFrame frame) {
try {
constant = readConstantNode.lookupConstantNode.executeLookupConstant(frame, module, name);
} catch (RaiseException e) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getException()) == context.getCoreLibrary().getNameErrorClass()) {
if (Layouts.BASIC_OBJECT.getLogicalClass(e.getException()) == coreLibrary().getNameErrorClass()) {
// private constant
return nil();
}