Skip to content

Primitive receivers: method_missing, Symbol#method after undef, block-form reopen #393

Open

Description

@linyiru

Found while fixing the #387 review. Two gaps around primitive receivers, both on master as well (verified 2026-09-24, CRuby 3.4.8 as oracle).

1. A user method_missing is never reached for a Symbol receiver.

class Object; def method_missing(n, *a) = [:mm, n, *a]; end
p :abc.nope(1)   # CRuby: [:mm, :nope, 1]   rubyrs: NoMethodError

The same applies after class Symbol; undef_method :start_with?; end (CRuby: [:mm, :start_with?, "a"]).

2. Symbol#method ignores an undef.

class Symbol; undef_method :length; end
:abc.method(:length)   # CRuby: NameError   rubyrs: #<Method: Symbol#length()>

The call itself raises NoMethodError correctly (the do_call gate from #387); only method() / Method-object creation misses the sym_undefed tombstone check.

3. Block-form calls on primitives ignore a reopen.

class String; def each_char(*) = :own; end
p "ab".each_char { }   # CRuby: :own   rubyrs: "ab"
class Integer; def times = :own; end
p 3.times { }          # CRuby: :own   rubyrs: 3

The block-form reopen gate (the prim_reopen_mask twin in dispatch.rs) catches each_byte, but each_char and Integer#times take an earlier block fast path that runs before it. Prepending a module shows the same symptom.

Acceptance

  • A diff fixture covering all three cases; delete it from quarantine once green.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions