Skip to content

Commit

Permalink
Adds a couple of code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Sep 16, 2023
1 parent 2a618da commit d043718
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/zeitwerk/loader/callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ def on_file_autoloaded(file)
else
msg = "expected file #{file} to define constant #{cpath}, but didn't"
log(msg) if logger

# Ruby still keeps the autoload defined, but we remove it because the
# contract in Zeitwerk is more strict.
crem(*cref)

# Since the expected constant was not defined, there is nothing to unload.
# However, if the exception is rescued and reloading is enabled, we still
# need to deleted the file from $LOADED_FEATURES.
to_unload[cpath] = [file, cref] if reloading_enabled?

raise Zeitwerk::NameError.new(msg, cref.last)
end
end
Expand Down

0 comments on commit d043718

Please sign in to comment.