haXe Forum > Function declaration causes error
-
Michael Lagutko Sep 03 at 16:53
Function declaration as property causes "too much recursion" error on Firefox
JavaScript crushes on Firefox with the following error:
error: InternalError: too much recursionHere is sample:
class Test {
static function main() {
var obj1 = new WithFunction(WithFunction.EqualF());
for (i in 0...1000) {
obj1 = obj1.clone();
}obj1.test(1, 2);
}
}typedef TestFunction = Int -> Int -> Bool
class WithFunction{
public var fun (default, null): TestFunction;public function new(funArg: TestFunction) {this.fun = funArg; }
public function clone(): WithFunction {
return new WithFunction(fun);
}
public function test(val1: Int, val2: Int): Bool {
return fun(val1, val2);
}
public static function EqualF(): TestFunction {
return function(v1: Int, v2: Int) {
return v1 == v2;
};
}
}The declaration "public var fun (default, null): TestFunction;" causes the problem. If the declaration "public var fun: TestFunction;" is used then everything works fine.
Platform:
OSX 10.5.8
Firefox: 3.6.8 -
Niel Drummond Sep 04 at 16:29
I cannot reproduce this (Linux, same Firefox version). What version of haxe are you using ? I'm on 2.05