Skip to content

Fix NameError in ZeitwerkClassGetter for collapsed Zeitwerk paths#339

Open
KaiyuanMa wants to merge 1 commit into
drwl:mainfrom
KaiyuanMa:main
Open

Fix NameError in ZeitwerkClassGetter for collapsed Zeitwerk paths#339
KaiyuanMa wants to merge 1 commit into
drwl:mainfrom
KaiyuanMa:main

Conversation

@KaiyuanMa
Copy link
Copy Markdown

@KaiyuanMa KaiyuanMa commented May 19, 2026

Summary

Got an error when running annotaterb:

undefined local variable or method 'file' for an instance of AnnotateRb::ModelAnnotator::ZeitwerkClassGetter
undefined local variable or method 'file' for an instance of AnnotateRb::ModelAnnotator::ZeitwerkClassGetter
undefined local variable or method 'file' for an instance of AnnotateRb::ModelAnnotator::ZeitwerkClassGetter
undefined local variable or method 'file' for an instance of AnnotateRb::ModelAnnotator::ZeitwerkClassGetter
undefined local variable or method 'file' for an instance of AnnotateRb::ModelAnnotator::ZeitwerkClassGetter
undefined local variable or method 'file' for an instance of AnnotateRb::ModelAnnotator::ZeitwerkClassGetter
undefined local variable or method 'file' for an instance of AnnotateRb::ModelAnnotator::ZeitwerkClassGetter

The block on line 52 referenced a local variable file that does not exist in this scope. Any model file falling inside a Zeitwerk collapse path raised NameError: undefined local variable or method 'file', which was swallowed by the rescue NameError on line 77 and returned nil, silently breaking annotation for collapsed-path models.

Change

lib/annotate_rb/model_annotator/zeitwerk_class_getter.rb:52file.include?(...)@file.include?(...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant