Closed nadako closed 10 years ago
Probably this is the case when inlining should not occur but still does. I got another one here:
class Sample
{
static function main()
{
var o:Dynamic = {f: true};
if (Reflect.field(o, "f"))
{
trace(o.f);
}
}
}
js:
Sample.main = function() {
var o = { f : true};
if((function($this) {
var $r;
var v = null;
try {
v = o.f;
} catch( e ) {
}
$r = v;
return $r;
}(this))) console.log(o.f);
};
We should not mark as inline Reflect.field if it contains a try/catch
Yeah, but shouldn't the inliner be smart here and disallow inlining in this case of usage?
We removed the JS-specific inlining restrictions recently, but I agree Reflect.field should not be inline.
@waneck-mode I have a filter for genc which removes "statements" in some places: https://github.com/waneck/haxe-genc/blob/genc/filters.ml#L111
The generated JS output with that would look like this:
Main.main = function() {
var o = { f : true};
var _g8;
var v = null;
try {
v = o.f;
} catch( e ) {
}
_g8 = v;
if(_g8) o.f;
};
It still has too many locals, but that's a job for a separate filter.
Since the JS inlining restrictions are back in place this issue is "resolved".
Subj. Haxe example:
Generated JS:
AST: