E07170: a developer coded constructor(s) are required where uninitialised properties are used
What went wrong
Your class has properties that aren't initialized and doesn't have a constructor to initialize them. Properties must be either initialized at declaration or set in a constructor.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 104 (Why does EK9 require explicit constructo...)
How to fix it
- Initialize properties at declaration with values
- Or add constructor to initialize properties
- Or use 'default' constructor for auto-initialization
Common causes
- Properties declared without values and no constructor
- Forgot to provide default values or constructor
- Incomplete class definition
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07170: a developer coded constructor(s) are required where uninitialised properties are used
#!ek9 defines module error.e07170.bad defines class //name is declared unset, and no constructor sets it Greeter name as String? rename() -> newName as String name: newName default operator ?
Fixed: Write a constructor that sets the property
#!ek9 defines module error.e07170.good defines class Greeter name as String? default private Greeter() Greeter() -> initialName as String this.name: initialName rename() -> newName as String name: newName default operator ?
Found a problem?
If EK9 reported E07170 for a program you think is valid, or did not report it where it should have, use the compiler form with the smallest program that shows it. If this page is wrong or unclear, use the documentation form. Both are at github.com/ek9lang/ek9-issues.