Skip to content

Fix Ruby 4.0 warning in default before_template and after_template#986

Merged
joeldrapper merged 1 commit into
yippee-fun:mainfrom
ErnaneJ:fix/ruby4-block-warning-before-after-template
Jul 14, 2026
Merged

Fix Ruby 4.0 warning in default before_template and after_template#986
joeldrapper merged 1 commit into
yippee-fun:mainfrom
ErnaneJ:fix/ruby4-block-warning-before-after-template

Conversation

@ErnaneJ

@ErnaneJ ErnaneJ commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #985

SGML#call passes the caller's block to before_template and after_template via &block, but the default no-op implementations had no block parameter. Ruby 4.0 warns about this:

warning: the block passed to 'before_template' may be ignored
warning: the block passed to 'after_template' may be ignored

I added (&) to both signatures so they accept the block without binding it to a variable. Subclasses that override these methods won't be affected.

…pt a block

The call site in SGML#call passes a block to both methods via `&block`,
but the default no-op implementations had no block parameter. Ruby 4.0
warns about this ("block passed to method may be ignored"). Adding `(&)`
to both signatures silently accepts the block without using it.
@ErnaneJ
ErnaneJ force-pushed the fix/ruby4-block-warning-before-after-template branch from 032d92e to f230f2e Compare July 14, 2026 03:36
@joeldrapper

Copy link
Copy Markdown
Collaborator

Thanks

@joeldrapper
joeldrapper merged commit f1c7f11 into yippee-fun:main Jul 14, 2026
0 of 15 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.

Ruby 4.0 warning: block passed to before_template/after_template "may be ignored"

2 participants