Skip to content

Commit

Permalink
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion spec/truffle/tags/core/module/autoload_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fails:Module#autoload ignores the autoload request if the file is already loaded
fails:Module#autoload does not remove the constant from the constant table if the loaded files does not define it
fails:Module#autoload calls #to_path on non-string filenames
fails:Module#autoload calls #to_path on non-String filename arguments
Original file line number Diff line number Diff line change
@@ -518,6 +518,7 @@ public abstract static class AutoloadNode extends CoreMethodNode {
@Child private StringNodes.EmptyNode emptyNode;
private final ConditionProfile invalidConstantName = ConditionProfile.createBinaryProfile();
private final ConditionProfile emptyFilename = ConditionProfile.createBinaryProfile();
private final ConditionProfile alreadyLoaded = ConditionProfile.createBinaryProfile();

public AutoloadNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -549,6 +550,10 @@ private RubyBasicObject autoload(RubyModule module, String name, RubyString file
throw new RaiseException(getContext().getCoreLibrary().argumentError("empty file name", this));
}

if (alreadyLoaded.profile(module.getConstants().get(name) != null)) {
return nil();
}

module.setAutoloadConstant(this, name, filename);

return nil();

0 comments on commit e165d8b

Please sign in to comment.