intellij-haxe
intellij-haxe copied to clipboard
Typedef extending shows error.
Case 1
package ;
typedef TypedefInt = {
var int:Int;
}
typedef TypedefFinal = {
> TypedefInt;
}
class TestClass {
public static function init() {
var typedefFinal:TypedefFinal;
trace(typedefFinal.int);
}
}
Case 2
package ;
typedef TypedefInt = {
var int:Int;
}
typedef TypedefFinal = {
> TypedefInt,
}
class TestClass {
public static function init() {
var typedefFinal:TypedefFinal;
trace(typedefFinal.int);
}
}
Single typedef extending shows an error, but if you add a variable below it as in the image below, the problem disappears.
Case 3
package ;
typedef TypedefInt = {
var int:Int;
}
typedef TypedefString = {
var string:String;
}
typedef TypedefFinal = {
> TypedefInt;
var a:String;
> TypedefString;
var b:String;
}
class TestClass {
public static function init() {
var typedefFinal:TypedefFinal;
trace(typedefFinal);
trace(typedefFinal);
}
}
However, if you extend more than one typedef as in the image, adding variables does not solve the problem.
neither Case 1 nor Case 3 seems to be valid Haxe code when trying to compile it with try.haxe.org
Case 1 is incorrect because you should not use ; the fact that it removes the error highlighting when ; is added is probably just a bug, it should be ,
Case 2 while strange code (typdef extending without adding anything) compiles fine so the parser might need some tweaks.
Case 3 will not work, all extends must be before any new members are added as far as i know.
i would recommend using the Haxe 4 syntax unless you need to target to target 3.x https://haxe.org/manual/types-structure-extensions.html