Skip to content

Commit 2ea2018

Browse files
committed
[GR-28844] Fix constant lookup from C.
PullRequest: truffleruby/2342
2 parents f1e6d6b + 8b5e05f commit 2ea2018

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

spec/ruby/optional/capi/fixtures/module.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class A
1313
autoload :D, File.expand_path('../const_get.rb', __FILE__)
1414

1515
X = 1
16+
Q = 1
17+
R = 2
18+
S = 3
19+
T = 5
1620
end
1721

1822
class B < A

spec/ruby/optional/capi/module_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@
134134
@m.rb_const_get(CApiModuleSpecs::A, :X).should == 1
135135
end
136136

137+
it "returns a constant defined in the module for multiple constants" do
138+
[:Q, :R, :S, :T].each { |x| @m.rb_const_get(CApiModuleSpecs::A, x).should == CApiModuleSpecs::A.const_get(x) }
139+
end
140+
137141
it "returns a constant defined at toplevel" do
138142
@m.rb_const_get(CApiModuleSpecs::A, :Integer).should == Integer
139143
end

src/main/java/org/truffleruby/language/constants/LookupConstantNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected RubyConstant lookupConstantUncached(RubyModule module, String name, bo
8181
ConstantLookupResult constant = doLookup(module, name);
8282
boolean isVisible = isVisible(module, constant);
8383

84-
if (!isValidConstantNameProfile.profile(checkName && isValidConstantName(name))) {
84+
if (!isValidConstantNameProfile.profile(isValidName(checkName, name))) {
8585
throw new RaiseException(getContext(), coreExceptions().nameErrorWrongConstantName(name, this));
8686
} else if (isVisibleProfile.profile(!isVisible)) {
8787
throw new RaiseException(getContext(), coreExceptions().nameErrorPrivateConstant(module, name, this));

0 commit comments

Comments
 (0)