Project

General

Profile

Actions

Feature #16043

closed

`$LOAD_PATH.resolve_feature_path` should not raise

Added by deivid (David Rodríguez) over 2 years ago. Updated 10 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:94135]

Description

When I first tried this method, I was expecting it to return nil when the given feature is not found. This is because I read in the docs and discussion that this method only searches the feature in the LOAD_PATH, but does not attempt to load it. Raising a load error makes it look that this method tries to load the feature, but I don't think it does that.

Also returning nil seems friendlier to me because the "feature not found" case is more like an expected outcome of the method than a real error condition, so in most usages this error will actually be rescued for control flow.

I attach a patch with the change, and link to the GH PR: https://github.com/ruby/ruby/pull/2317.


Files

Updated by shevegen (Robert A. Heiler) over 2 years ago

read in the docs and discussion that this method only searches the feature in the LOAD_PATH,
but does not attempt to load it. Raising a load error makes it look that this method tries
to load the feature, but I don't think it does that.

I had a look at the tracker:

https://bugs.ruby-lang.org/issues/15230

And I agree with you in the sense that mame did not mandate that the method should raise,
so it probably should not raise (or it should be mentioned in the documentation, IMO).

I have no opinion on what it should return but I think either way it would be best to
specify it, to less confusion by other ruby users. It may be best to ask mame directly
whether he agrees with your comment + patch. :)

Updated by deivid (David Rodríguez) over 2 years ago

Thanks for having a look and for linking to the original discussion!

Actions #3

Updated by jeremyevans0 (Jeremy Evans) about 2 years ago

  • Backport deleted (2.5: UNKNOWN, 2.6: UNKNOWN)
  • ruby -v deleted (ruby 2.7.0dev)
  • Tracker changed from Bug to Feature

Updated by Eregon (Benoit Daloze) about 1 year ago

Agreed, I added it to the next dev-meeting agenda (#17299)

Updated by matz (Yukihiro Matsumoto) about 1 year ago

Accepted.

Matz.

Actions #6

Updated by znz (Kazuhiro NISHIYAMA) 10 months ago

  • Status changed from Open to Closed

Applied in changeset git|4dfc5496b7b64a063b36cbabe95b43abe9fb48cd.


Add NEWS entry for [Feature #16043]

Actions

Also available in: Atom PDF