fix: remove default constructors and require explicit construct new() for all user classes
The compiler no longer auto-generates a default `new()` constructor for classes. All classes must now explicitly define `construct new() {}` to be instantiable. This change removes the `createDefaultConstructor` function from the compiler, eliminates the `return_this` primitive used by Object's default initializer, and adds explicit constructors to all test and example classes. Core metaclasses (Bool, Class, Null, Num, Object, Range, Sequence) now correctly reject `new()` calls with runtime errors.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
class Foo {
|
||||
construct new() {}
|
||||
|
||||
set(a, b, c, d, e) {
|
||||
__a = a
|
||||
__b = b
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
class Outer {
|
||||
construct new() {}
|
||||
|
||||
static staticMethod {
|
||||
__field = "outer"
|
||||
IO.print(__field) // expect: outer
|
||||
|
||||
class Inner {
|
||||
construct new() {}
|
||||
|
||||
static staticMethod {
|
||||
__field = "inner"
|
||||
IO.print(__field) // expect: inner
|
||||
@@ -19,6 +23,8 @@ class Outer {
|
||||
IO.print(__field) // expect: outer
|
||||
|
||||
class Inner {
|
||||
construct new() {}
|
||||
|
||||
instanceMethod {
|
||||
__field = "inner"
|
||||
IO.print(__field) // expect: inner
|
||||
|
||||
Reference in New Issue
Block a user