= Deimos Jesse Brault 0.1.0 :toc: == Compile Error Explanations === Not more than one constructor Classes may have up to only one constructor. The following does not compile: [source] ---- class Foo ctor(bar: Int) end ctor(baz: String) end // Error end ---- === Field must be initialized All class fields must be initialized in their declaration, or in the constructor. It is an error to leave a field uninitialized. [source] ---- class Foo bar: Int // Error: no initializer end class Bar baz: Int // Error: no initializer ctor() // some other stuff end end ---- === Use of field before initialization A field _without_ a declared initializer (i.e., one present at its declaration, not the constructor) may not be read in the initializer of any other field or constructor variable, as the language does not guarantee a specific ordering of field initialization and cannot statically analyze field/variable dependencies. [source] ---- class Foo bar: Int baz = bar // Error end class Bar foo: Int baz = fnWithArg(foo) // Error end class Baz foo: Int qux: String ctor(baz: String) qux = foo + baz // Error: attempt to read uninitialized foo end end ---- The exception to this is reading the field inside another field's initializer *only* when that expression is itself a closure. [source] ---- class Foo bar: Int baz = { bar } // OK ctor(bar: Int) self.bar = bar end end ----