[ruby-core:94135] [Ruby master Bug#16043] `$LOAD_PATH.resolve_feature_path` should not raise

From: deivid.rodriguez@...
Date: 2019-08-04 11:16:21 UTC
List: ruby-core #94135
Issue #16043 has been reported by deivid (David Rodr刕uez).

----------------------------------------
Bug #16043: `$LOAD_PATH.resolve_feature_path` should not raise
https://bugs.ruby-lang.org/issues/16043

* Author: deivid (David Rodr刕uez)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
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--------------------------------
0001-LOAD_PATH.resolve_feature_path-should-not-raise.patch (1.13 KB)


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

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next