Skip to content

Write annotations of constant, global, and class/module alias declarations - #3246

Merged
ksss merged 1 commit into
ruby:masterfrom
ksss:writer-decl-annotations
Oct 19, 2026
Merged

ksss merged 1 commit into
ruby:masterfrom
ksss:writer-decl-annotations

Conversation

@ksss

@ksss ksss commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

RBS::Writer#write_decl does not call write_annotation for Constant, Global, ClassAlias, and ModuleAlias, so annotations on those declarations are dropped when writing.

_, _, decls = RBS::Parser.parse_signature("%a{deprecated}\nclass A = B\n")
RBS::Writer.new(out: $stdout).write(decls)
# => class A = B

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.annotations right after write_comment, the same way TypeAlias, Class, Module, and Interface already do.

Notes

🤖 Generated with Claude Code

`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>
@ksss
ksss added this pull request to the merge queue Oct 19, 2026
Merged via the queue into ruby:master with commit 78654c9 Oct 19, 2026
25 checks passed
@ksss
ksss deleted the writer-decl-annotations branch October 19, 2026 09:48
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