Enum abstract not checked
ncannasse opened this issue · comments
Surprisingly the following compile while it shouldn't ( T should be Int on step++)
enum abstract T(Int) {
var Start;
var End;
}
class Test {
static var step(default,set) : T;
static function set_step(s:T) { step = s; return s; }
static function main() {
step++;
}
}
It's even worse:
class Main {
static var step(default, set):String;
static function set_step(s:String) {
step = s;
return s;
}
static function main() {
step++;
}
}
(Edit: Well that would actually make some sense with String and +
specifically, but it admits any type here it seems.)
Is it a regression ? It seems quite bad, we want the fix to be merged asap @yuxiaomao :D
According to my brief try.haxe investigations it was a regression from 4.1 to 4.2, so quite old.
I'll pull the linked fix and will keep this issue open as a reminder to add tests.
The case of string++ can still compile without warning. Is that normal?
Good question... when accessors are involved, a++
is pretty much treated like a += 1
and this has always been admitted for operands of type String
and Int
. But it doesn't really look like it should work.