{"action":"created","issue":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4354","labels_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4354/labels{/name}","comments_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4354/comments","events_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4354/events","html_url":"https://github.com/HaxeFoundation/haxe/issues/4354","id":89628234,"number":4354,"title":"haxe generates invalid bytecode for Array::remove and Math::isNaN when targeting swc","user":{"login":"ktimothy","id":1556432,"avatar_url":"https://avatars.githubusercontent.com/u/1556432?v=3","gravatar_id":"","url":"https://api.github.com/users/ktimothy","html_url":"https://github.com/ktimothy","followers_url":"https://api.github.com/users/ktimothy/followers","following_url":"https://api.github.com/users/ktimothy/following{/other_user}","gists_url":"https://api.github.com/users/ktimothy/gists{/gist_id}","starred_url":"https://api.github.com/users/ktimothy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktimothy/subscriptions","organizations_url":"https://api.github.com/users/ktimothy/orgs","repos_url":"https://api.github.com/users/ktimothy/repos","events_url":"https://api.github.com/users/ktimothy/events{/privacy}","received_events_url":"https://api.github.com/users/ktimothy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-19T18:24:04Z","updated_at":"2015-06-20T08:29:25Z","closed_at":null,"body":"Haxe does not parse Array::remove correctly when targeting swc.\r\n\r\nI make swc with following class:\r\n\r\nTest.hx\r\n```haxe\r\npackage ;\r\n\r\nclass Test\r\n{\r\n\tpublic static function run():Void\r\n\t{\r\n\t\tvar array:Array<Int> = [];\r\n\r\n\t\tarray.remove(1);\r\n\t}\r\n}\r\n\r\n```\r\n\r\nCompile it with command ```haxe -cp ./ -swf lib.swc Test```. Then I use the library in flash code:\r\nMain.as\r\n```actionscript\r\npackage\r\n{\r\n\timport flash.display.Sprite;\r\n\r\n\tpublic class Main extends Sprite\r\n\t{\r\n\t\tpublic function Main()\r\n\t\t{\r\n\t\t\tTest.run();\r\n\t\t}\r\n\t}\r\n}\r\n````\r\n\r\nCompile it with command ```mxmlc -library-path+=./lib.swc -output main.swf Main.as ```.\r\n\r\nI run main.swf in debugger player and receive an error:\r\n\r\n```\r\nTypeError: Error #1006: remove is not a function.\r\n\tat Test$/run()\r\n\tat Main()\r\n```\r\n\r\nThats the output from decompiler (the same in main.swf and library.swf from lib.swc):\r\n```actionscript\r\npackage\r\n{\r\n    public class Test\r\n    {\r\n        public static function run():void\r\n        {\r\n            var _local1:array = [];\r\n            _local1.remove(1);\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nThe same thing happens to Math.isNaN: it must be compiled to global function isNaN(), but bytecode shows that it tries to call isNaN from class Math, like in the haxe code."},"comment":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/comments/113730094","html_url":"https://github.com/HaxeFoundation/haxe/issues/4354#issuecomment-113730094","issue_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4354","id":113730094,"user":{"login":"ktimothy","id":1556432,"avatar_url":"https://avatars.githubusercontent.com/u/1556432?v=3","gravatar_id":"","url":"https://api.github.com/users/ktimothy","html_url":"https://github.com/ktimothy","followers_url":"https://api.github.com/users/ktimothy/followers","following_url":"https://api.github.com/users/ktimothy/following{/other_user}","gists_url":"https://api.github.com/users/ktimothy/gists{/gist_id}","starred_url":"https://api.github.com/users/ktimothy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktimothy/subscriptions","organizations_url":"https://api.github.com/users/ktimothy/orgs","repos_url":"https://api.github.com/users/ktimothy/repos","events_url":"https://api.github.com/users/ktimothy/events{/privacy}","received_events_url":"https://api.github.com/users/ktimothy/received_events","type":"User","site_admin":false},"created_at":"2015-06-20T08:29:25Z","updated_at":"2015-06-20T08:29:25Z","body":"Yeah, It works. But patching prototypes in runtime is not what I need.\r\n\r\nLook, you can convert Math.isNaN() to isNaN() for javascript target, but cannot do the same for flash? Sounds weird. Why was it so necessary to patch prototypes in actionscript?"}}