Skip to content

[js] Passing String.charAt takes weird closure #5568

Description

@Simn
class Main {
    static function main() {
        var str = "fdsf";
        run(str.charAt);
    }

    static function run(cb:Int->String) trace(cb(2));
}

Generated:

// Generated by Haxe 3.3.0
(function () { "use strict";
var Main = function() { };
Main.main = function() {
    Main.run($bind("fdsf","fdsf".charAt));
};
Main.run = function(cb) {
    console.log(cb(2));
};
var $_, $fid = 0;
function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $fid++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = function(){ return f.method.apply(f.scope, arguments); }; f.scope = o; f.method = m; o.hx__closures__[m.__id__] = f; } return f; }
Main.main();
})();

Errors with TypeError: Cannot assign to read only property 'hx__closures__' of fdsf. Not a regression and might be broken on other targets too.

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions