Project

General

Profile

Actions

Bug #21708

open

Ruby 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

Added by jfi (James Inman) about 5 hours ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:123890]

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

No data to display

Actions

Also available in: PDF Atom