Repository navigation
Check irb_require loaded files against the load path - #1262
Open
Shaisolaris wants to merge 2 commits into
Open
Shaisolaris wants to merge 2 commits into
Shaisolaris wants to merge 2 commits into
Conversation
The already-loaded check matched any $LOADED_FEATURES entry that ends with /name.rb, so a file loaded from another directory with the same basename made irb_require skip the requested file and return false. For example, irb_require 'util' did nothing because rubygems/util.rb is loaded. Compare against the names irb_require pushes and the paths under each $LOAD_PATH directory instead.
The file loaded with Kernel#require contained a bare string literal, which prints "possibly useless use of a literal in void context" when warnings are enabled, so assert_empty(err) failed in CI.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #1254, the already-loaded check in
irb_requirematches any$LOADED_FEATURESentry that ends with/<name>.rb. A file with the same basename in another directory now counts as loaded, soirb_requireskips the requested file and returnsfalse.For example, with
util.rbin a directory on the load path:The same happens for names like
set,parserorversiononce a library with such a file (for examplepsych/set.rb) has been loaded.This change compares the entries with the names
irb_requireitself pushes and with<dir>/<name>,<dir>/<name>.rband<dir>/<name>.ofor each$LOAD_PATHdirectory. A file thatrequireloaded from the load path is still skipped, sotest_irb_require_skips_file_already_loaded_by_requirefrom #1254 and the foo/foo2 test from #1253 still pass.Tests:
test_irb_require_loads_file_with_same_name_as_loaded_file_in_other_directory. It fails on master and passes with this change.test/irb/test_command.rb: 57 tests pass locally (Ruby 3.3.8).test/irb/test_*.rbfiles loaded together: the same 2 failures on master and with this change (test_object_inspection_handles_basic_object,test_use_tracer_enabled_when_gem_is_available), so they are not related. I did not run RuboCop or the CI matrix.#1257 also changes
irb_require(the.rbbranch); the two changes touch different lines.