Cannot use default parameters on init method
supercooldave opened this issue · comments
Using default parameters on the init
method results in compilation errors. For example,
local class A
-- does not compile
def init(i : int = 0) : unit
println(i)
end
-- compiles and works
def other(i : int = 0) : unit
println(i)
end
end
results in error:
"Init.enc" (line 3, column 3)
Constructor method 'init' can only be called during object creation
In expression:
this.init(0)
In expression:
return(this.init(0))
In method '_init1' of type 'unit'
In class 'A'
This is undoubtedly due to the way methods using default parameters are compiled, which is incompatible with the restrictions on init
.