Skip to content

Fix NameError in ZeitwerkClassGetter for collapsed Zeitwerk paths#339

Merged
OdenTakashi merged 1 commit into
drwl:mainfrom
KaiyuanMa:main
May 20, 2026
Merged

Fix NameError in ZeitwerkClassGetter for collapsed Zeitwerk paths#339
OdenTakashi merged 1 commit into
drwl:mainfrom
KaiyuanMa:main

Conversation

@KaiyuanMa

@KaiyuanMa KaiyuanMa commented May 19, 2026

Copy link
Copy Markdown
Contributor

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?(...).

@OdenTakashi OdenTakashi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

@OdenTakashi OdenTakashi merged commit 9538099 into drwl:main May 20, 2026
14 checks passed
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.

2 participants