Macro | using Lambda makes "invalid call" error

73 views
Skip to first unread message

michael solomon

unread,
Feb 10, 2017, 12:13:09 PM2/10/17
to Haxe
Hey,
I'm trying to fix a macro lib(hxAnonCls), that broken somewhere after 3.1.3, the problem is in this line:
(untyped v.meta:Metadata).exists(function(m) return m.name == ":unbound")

v is type of haxe.macro.TVar

And this is the error:
E:\haxe\haxe\std/Lambda.hx:142: characters 12-14 : Invalid call
hxAnonCls
/Macros.hx:334: characters 9-82 : Called from
E
:\haxe\haxe\std/neko/_std/Array.hx:275: characters 12-18 : Called from
hxAnonCls
/Macros.hx:467: characters 14-37 : Called from
E
:\haxe\haxe\std/neko/_std/Array.hx:275: characters 12-18 : Called from
hxAnonCls
/Macros.hx:467: characters 14-37 : Called from
hxAnonCls
/Macros.hx:573: characters 9-28 : Called from
hxAnonCls
/Macros.hx:88: characters 7-26 : Called from
hxAnonCls
/AnonCls.hx:371: characters 18-55 : Called from
test
/Test.hx:50: lines 50-53 : Called from
Aborted

Thanks all!!
Micahel

Laurence Taylor

unread,
Feb 10, 2017, 1:21:43 PM2/10/17
to haxe...@googlegroups.com

try in hxAnonCls/hxAnonCls/Macros.hx

around line 332

var meta = (untyped v.meta:Metadata);
var res  = meta == null ? false : meta.exists(function(m) return m.name == ":unbound");

if (res)
    macro @:pos(te.pos) untyped $i{vName};
else
    macro @:pos(te.pos) $i{vName};

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Laurence Taylor

unread,
Feb 10, 2017, 1:23:22 PM2/10/17
to haxe...@googlegroups.com
It could also be dce stripping code, maybe

Laurence Taylor

unread,
Feb 10, 2017, 1:26:42 PM2/10/17
to haxe...@googlegroups.com

Wait, the error is from Lambda.hx, so:

var meta = (untyped v.meta:Metadata);
var res  = meta == null ? false : meta.exists(function(m) return m!=null && m.name == ":unbound");

if (res)
    macro @:pos(te.pos) untyped $i{vName};
else
    macro @:pos(te.pos) $i{vName};

michael solomon

unread,
Feb 10, 2017, 1:33:16 PM2/10/17
to Haxe

Laurence Taylor

unread,
Feb 10, 2017, 6:21:34 PM2/10/17
to haxe...@googlegroups.com
Invalid Call is an error Nekovm issues, normally when a property is accessed on a null value. the thing to do is assertions or traces on values on the lines from the error callstack to figure out where the unexpected null is coming from.

michael solomon

unread,
Feb 11, 2017, 11:52:33 AM2/11/17
to Haxe
digging more in the code and find that it isn't able to iterate over v.meta, i.e:
trace(1);
for (x in (untyped v.meta:Metadata)){
   trace
(x);
}
trace(2);

output:
hxAnonCls/Macros.hx:333: 1
hxAnonCls/Macros.hx:337: 2

no print in the middle and v is no empty, the trace of v.meta is:
haxe\std/Lambda.hx:142: { ??? => #function:1, add => #function:3, get => #function:0, has => #function:1, remove => #function:1 }

any clue?

michael solomon

unread,
Feb 13, 2017, 4:03:55 PM2/13/17
to Haxe


On Friday, February 10, 2017 at 7:13:09 PM UTC+2, michael solomon wrote:
Reply all
Reply to author
Forward
0 new messages