Skip to content

Poly (Time | user class) dispatch loses the builtin Time#strftime arm: NoMethodError #7334

Description

@rubys

A user class that defines strftime makes Time#strftime raise NoMethodError when the receiver is poly (Time | UserClass): the dispatch only has the user arm. A monomorphic Time receiver is fine.

Same family as #3459 / #4413 (builtin arm lost under poly dispatch), not covered for Time#strftime.

class Date
  def initialize(y); @y = y; end
  def strftime(p); "D#{@y}"; end
end
def fmt(t)
  t.strftime("%Y")
end
puts fmt(Time.at(0).utc)
puts fmt(Date.new(3))

CRuby:

1970
D3

Spinel (ab60de7):

undefined method 'strftime' for an instance of Time (NoMethodError)

Context: roundhouse PR rubys/roundhouse#423 adds a program-defined Date to the Spinel runtime; every Campfire page then 500s on Time#strftime.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions