plum icon indicating copy to clipboard operation
plum copied to clipboard

init fails, incorrect number of arguments

Open Wouter1 opened this issue 1 year ago • 0 comments

Try this code

from plum import dispatch

class A:
  @dispatch
  def __init__(self):
    self.__init__(1)
  @dispatch
  def __init__(self, x:int):
    print(str(x))

class B(A):
  def __init__(self):
    super().__init__()

B()

Expected: B is constructed with default value 1

Actual:

TypeError: __init__() takes 1 positional argument but 2 were given

I'm not sure what is going on as constructing A() works fine.

Note the print is just for clarity, normally some field initialization would happen there.

Wouter1 avatar Nov 06 '24 15:11 Wouter1