Skip to content

Commit

Permalink
$LOAD_PATH.resolve_feature_path should not raise
Browse files Browse the repository at this point in the history
I think it's more friendly and easier to work with to return `nil` when
the feature is not found in the $LOAD_PATH.
  • Loading branch information
deivid-rodriguez authored and znz committed Feb 16, 2021
1 parent 37b90bc commit 02151da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion load.c
Expand Up @@ -991,7 +991,7 @@ rb_resolve_feature_path(VALUE klass, VALUE fname)
sym = ID2SYM(rb_intern("so"));
break;
default:
load_failed(fname);
return Qnil;
}

return rb_ary_new_from_args(2, sym, path);
Expand Down
4 changes: 4 additions & 0 deletions test/ruby/test_require.rb
Expand Up @@ -857,5 +857,9 @@ def test_resolve_feature_path
$:.replace(paths)
$".replace(loaded)
end

def test_resolve_feature_path_with_missing_feature
assert_nil($LOAD_PATH.resolve_feature_path("superkalifragilisticoespialidoso"))
end
end
end

0 comments on commit 02151da

Please sign in to comment.