Boo

Calling a constructor overload calls $initializer$ again

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.8.2, 0.9
  • Fix Version/s: 0.9
  • Component/s: Compiler
  • Labels:
    None
  • Testcase included:
    yes
  • Number of attachments :
    0

Description

(and thus resets all fields with initializers)

Following code :

class Test:
     _x = "pre"

     def constructor():
           print _x

     def constructor(x as string):
           _x = x
           self()

Test("post")

Shows "pre", whereas it should obviously show "post".

We should either :
1) disallow using self() at any other position than first in the block (as what C# does in practice).
2) add a $initialized$ boolean field so that $initializer$ is executed only once.

(2) sounds more boo-ish imho, we could add the field only when there is more than one constructor on the object.

Activity

Hide
Cedric Vivier added a comment -

fixed in rev. 2992

Show
Cedric Vivier added a comment - fixed in rev. 2992

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: