Skip to content

Instantly share code, notes, and snippets.

@back2dos
Created May 1, 2013 16:09
Show Gist options
  • Select an option

  • Save back2dos/5496240 to your computer and use it in GitHub Desktop.

Select an option

Save back2dos/5496240 to your computer and use it in GitHub Desktop.
ECheckType and implicit conversion issue, haxe r6518
package ;
abstract MyAbstract(Int) {
public function new(v:Int) this = v;
@:from static function fromString(s:String) return new MyAbstract(Std.parseInt(s));
}
class Main {
#if !macro
static function main() {
var d:Dynamic = test();
trace(Std.is(d, Int));//false
var d:MyAbstract = test();
trace(Std.is(d, Int));//false
var d:MyAbstract = '5';
trace(Std.is(d, Int));//true
}
#end
macro static function test() {
return {
expr: haxe.macro.Expr.ExprDef.ECheckType(macro '5', macro: Main.MyAbstract),
pos: haxe.macro.Context.currentPos()
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment