"Invalid call" with erazor on Haxe 3.3.0/Neko 2.1.0

54 views
Skip to first unread message

x2f

unread,
Aug 12, 2016, 9:02:57 PM8/12/16
to Haxe
Hi, erazor seems to be broken for me on Neko 2.1.0 and haxe 3.3.0 (erazor 1.0.1 with hscript 2.0.7)

It used to work fine before upgrading, with Haxe 3.2 (and I believe the previous version of Neko), with the same version of erazor and hscript.

Erazor has an "EnhancedInterp.hx" with some neko-specific code (I removed the rest for clarity here)

```haxe
override function call( o : Dynamic, f : Dynamic, args : Array<Dynamic> ) : Dynamic {
//...
#elseif neko
var n : Int = untyped __dollar__nargs(f); // <--- line 53 Invalid call
while(args.length < n)
args.push(null);
return Reflect.callMethod(o,f,args);
#elseif flash9
//...
}
```

Running the demo on Neko on Windows shows the problem. It seems there is no such problem on Flash target.

```
$ haxe -main demo/Main.hx  -lib erazor --interp
...\haxelib\erazor/1,0,1/src/erazor/hscript/EnhancedInterp.hx:53: characters 24-42 : Invalid call
...\haxelib\hscript/2,0,7/hscript/Interp.hx:550: characters 9-33 : Called from
...\haxelib\hscript/2,0,7/hscript/Interp.hx:332: characters 11-28 : Called from
...\haxelib\hscript/2,0,7/hscript/Interp.hx:295: characters 8-15 : Called from
...\haxelib\hscript/2,0,7/hscript/Interp.hx:212: characters 10-17 : Called from
...\haxelib\hscript/2,0,7/hscript/Interp.hx:211: characters 2-5 : Called from
...\haxelib\hscript/2,0,7/hscript/Interp.hx:207: characters 9-25 : Called from
...\haxelib\erazor/1,0,1/src/erazor/Template.hx:71: characters 2-25 : Called from
...\haxelib\erazor/1,0,1/src/demo/Main.hx:56: characters 19-38 : Called from
?:1: characters 1048575-1050622 : Called from
Aborted
```



x2f

unread,
Aug 12, 2016, 10:11:02 PM8/12/16
to Haxe
Actually digging a little bit further, it appears that hscript Interp.hx's fcall() function

```
function fcall( o : Dynamic, f : String, args : Array<Dynamic> ) : Dynamic {
return call(o, get(o, f), args);
}
```

... and get(o,f) calls `Reflect.getProperty(o, f)`

fcall receives an object erazor.Output with a method "add", which it fails to retrieve from the object (`get(o,f)` returns null).

Now, this might be because erazor.Output derives from StringBuf which defines `public inline function add<T>( x : T ) : Void`

So is it possible that Haxe 3.3 changes the behavior of `Reflect.getProperty(o, f)` in this case?

Nicolas Cannasse

unread,
Aug 13, 2016, 5:41:42 AM8/13/16
to haxe...@googlegroups.com
Le 13/08/2016 à 03:02, x2f a écrit :
> Hi, erazor seems to be broken for me on Neko 2.1.0 and haxe 3.3.0
> (erazor 1.0.1 with hscript 2.0.7)
>
> It used to work fine before upgrading, with Haxe 3.2 (and I believe the
> previous version of Neko), with the same version of erazor and hscript.
>
> Erazor has an "EnhancedInterp.hx" with some neko-specific code (I
> removed the rest for clarity here)

Yes, hscript.Interp was changed to use Reflect.getProperty instead of
Reflect.field in "get" function, however this shouldn't cause the
program to fail.

Could you submit an issue on github/haxe with a reproducible example
where Reflect.getProperty(obj,"add") != Reflect.field(obj,"add") ?

Best,
Nicolas

Andreas Mokros

unread,
Aug 13, 2016, 6:35:25 AM8/13/16
to haxe...@googlegroups.com
Hi.

On Fri, 12 Aug 2016 19:11:02 -0700 (PDT)
x2f <x.d...@gmail.com> wrote:
> So is it possible that Haxe 3.3 changes the behavior of
> `Reflect.getProperty(o, f)` in this case?

Probably StringBuf is removed by dce.
Try adding --macro keep('StringBuf') to your hxml or use the current git
version:
https://github.com/ufront/erazor
which has a extraParams.hxml for this.

--
Mockey

x2f

unread,
Aug 13, 2016, 11:42:06 AM8/13/16
to Haxe
Thanks Nicolas and Andreas.

Adding extraParams.hxml to erazor with --macro keep('StringBuf') solves the issue.

To make sure I made a small program with Reflect.getProperty(obj,"add") != Reflect.field(obj,"add")

```
class Toto extends StringBuf {
  public var tmp:Int;
}

class Main {
  static function main() {
    var obj = new Toto();
    trace('getProperty: ${Reflect.getProperty(obj,"add")}');
    if (Reflect.getProperty(obj,"add") == Reflect.field(obj,"add")) trace("Same");
    else  trace("Different");
  }
}
```

... with --macro keep('StringBuf') we get

```
Main.hx:10: getProperty: #function:1
Main.hx:11: Same
```

... without --macro keep('StringBuf') we get

```
Main.hx:10: getProperty: null
Main.hx:11: Same
```

So there is no issue with Reflect at all, just that StringBuf is removed by dce.

Thanks again!
Reply all
Reply to author
Forward
0 new messages