Repository navigation
Write annotations of constant, global, and class/module alias declarations - #3246
Merged
Merged
Conversation
`RBS::Writer#write_decl` did not call `write_annotation` for
`Constant`, `Global`, `ClassAlias`, and `ModuleAlias`, so `%a{...}`
on those declarations disappeared from the output. The annotations
were added to these AST nodes in 6f8d0f3, 1bc9bb4, and 075d27c,
but the writer was not updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
RBS::Writer#write_decldoes not callwrite_annotationforConstant,Global,ClassAlias, andModuleAlias, so annotations on those declarations are dropped when writing.Cause
#2302 made these declarations annotatable (6f8d0f3 for class/module aliases, 1bc9bb4 for globals, 075d27c for constants), but those commits only changed the AST and the parser. The writer was never updated.
Change
Each branch now calls
write_annotation decl.annotationsright afterwrite_comment, the same wayTypeAlias,Class,Module, andInterfacealready do.Notes
Writer#preserve_empty_linedoesn't consider annotations, which lie outside the declaration's location, so the writer inserts a blank line before any annotated declaration that has no comment. This already happens forTypeAliasandClasstoday, and it is left for a separate change.🤖 Generated with Claude Code