Skip to content

Commit f88710f

Browse files
committed
Merge pull request #325 in G/truffleruby from hash-code to master
* commit '35183dec0c13d5681eb21feda6a47259c89c2961': Object identity numbers should never be negative
2 parents 5d4f035 + 35183de commit f88710f

File tree

6 files changed

+10
-7
lines changed

6 files changed

+10
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Bug fixes:
66

77
* `Kernel#singleton_methods` now correctly ignores prepended modules of
88
non-singleton classes. Fixes loading `sass` when `activesupport` is loaded.
9+
* Object identity numbers should never be negative.
910

1011
# 1.0 RC 6
1112

mx.truffleruby/suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# We want tools to be reliably available with TruffleRuby, even with "mx build", so this is a static import.
99
"name": "tools",
1010
"subdir": True,
11-
"version": "342f380ccde5c53cbd84ba6816c4d3a927bb1160",
11+
"version": "9e2a5c512871727b89573da286169290c4373c69",
1212
"urls": [
1313
{"url": "https://github.com/graalvm/graal.git", "kind": "git"},
1414
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},

spec/truffle/interop/foreign_object_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
it "can be printed with #puts" do
1919
lambda {
2020
puts Truffle::Debug.foreign_object
21-
}.should output(/#<Foreign:0x\-?\h+>\n/)
21+
}.should output(/#<Foreign:0x\h+>\n/)
2222
end
2323

2424
it "can be printed with #p" do
2525
lambda {
2626
p Truffle::Debug.foreign_object
27-
}.should output(/#<Foreign:0x\-?\h+>\n/)
27+
}.should output(/#<Foreign:0x\h+>\n/)
2828
end
2929

3030
end

spec/truffle/interop/send_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
describe "Interop #__send__" do
1212

1313
it "can call special forms like outgoing #inspect" do
14-
Truffle::Debug.foreign_object.__send__(:inspect).should =~ /#<Foreign:0x\-?\h+>/
14+
Truffle::Debug.foreign_object.__send__(:inspect).should =~ /#<Foreign:0x\h+>/
1515
end
1616

1717
end

spec/truffle/interop/special_forms_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
end
7575

7676
it "#inspect returns a useful string" do
77-
Truffle::Debug.foreign_object.inspect.should =~ /#<Foreign:0x\-?\h+>/
77+
Truffle::Debug.foreign_object.inspect.should =~ /#<Foreign:0x\h+>/
7878
end
7979

8080
describe "#is_a?" do
@@ -178,7 +178,7 @@
178178
end
179179

180180
it "#__send__ can call special forms like outgoing #inspect" do
181-
Truffle::Debug.foreign_object.__send__(:inspect).should =~ /#<Foreign:0x\-?\h+>/
181+
Truffle::Debug.foreign_object.__send__(:inspect).should =~ /#<Foreign:0x\h+>/
182182
end
183183

184184
end

src/main/java/org/truffleruby/interop/InteropNodes.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,9 @@ public abstract static class InteropIdentityHashCodeNode extends CoreMethodArray
10141014
@Specialization
10151015
@TruffleBoundary
10161016
public int identityHashCode(Object value) {
1017-
return System.identityHashCode(value);
1017+
final int code = System.identityHashCode(value);
1018+
assert code >= 0;
1019+
return code;
10181020
}
10191021

10201022
}

0 commit comments

Comments
 (0)