HaxeFoundation / HaxeFoundation/haxe
[js] Passing String.charAt takes weird closure
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
``` haxe
class Main {
static function main() {
var str = "fdsf";
run(str.charAt);
}
static function run(cb:Int->String) trace(cb(2));
}
```
Generated:
``` js
// 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.
Contributor guide
Assessment
This issue has not been assessed yet.