Actions
Bug #21708
openRuby 3.4 Forwardable: setter delegations trigger SyntaxError from forwardable/impl.rb
Bug #21708:
Ruby 3.4 Forwardable: setter delegations trigger SyntaxError from forwardable/impl.rb
Description
-
forwardable: 1.3.3 (bundled stdlib) - OS: Ubuntu 24.04 (also reproducible on macOS)
- RUBYOPT / $DEBUG: default (but with $DEBUG=true or RUBYOPT=-d the errors are emitted)
Reproduction Script (minimal)¶
require "forwardable"
class Host
attr_accessor :scheme
end
class Delegator
extend Forwardable
def initialize
@host = Host.new
end
def_delegator :@host, :scheme=, :scheme=
def_delegator :@host, :scheme, :scheme
end
$DEBUG = true # force forwardable to log the SyntaxError
d = Delegator.new
d.scheme = "https"
puts d.scheme
Output running with ruby -d:
Exception 'SyntaxError' at .../forwardable/impl.rb:6 - syntax errors found
> 6 | BEGIN{throw tag}; ().scheme=
| ^ expected an expression after `=`
Despite the SyntaxError, the program continues, but stderr is flooded whenever a setter is delegated. Similar errors appear for any delegated setter (host=, port=, etc.), causing noise in test runs and CI logs.
Expected behavior¶
Delegating setter methods should not raise or log SyntaxError; forwardable should generate the delegator quietly, as in Ruby 3.3 and earlier.
Other reports¶
- ruby/forwardable issue #35 shows the same SyntaxError output pattern on Ruby 3.4: https://github.com/ruby/forwardable/issues/35
No data to display
Actions