Details
Description
when to define constructor() in global scope,
I think that the compiler should report an error then.
---sample code---
- the code has a bug purposely
class Rectangle:
_width as single
_height as single
def constructor(width as single, height as single):
_width = width
_height = height
virtual def GetArea():
return _width * _height
class Square(Rectangle):
def constructor(width as single):
super(width, width)
override def GetArea():
return _width * _width
----compile it----
>booc constructor.boo
Boo Compiler version 0.9.2.3383 (CLR 2.0.50727.4200)
constructor.boo(14,14): BCE0024: The type 'Rectangle' does not have a visible constructor
that matches the argument list '(single, single)'.
constructor.boo(16,18): BCE0060: 'Square.GetArea()': no suitable method found to override.
constructor.boo(9,16): BCE0005: Unknown identifier: '_width'.
constructor.boo(9,25): BCE0005: Unknown identifier: '_height'.
4 error(s).
am talking with kanryu in irc.
samples a little complex, heres a much easier example:
def constructor(): print("constructor") print("main")there's not really any way to access this constructor, should probably through an error since its "dead code."