{"action":"created","issue":{"url":"https://api.github.com/repos/Khan/Prototope/issues/25","labels_url":"https://api.github.com/repos/Khan/Prototope/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/Khan/Prototope/issues/25/comments","events_url":"https://api.github.com/repos/Khan/Prototope/issues/25/events","html_url":"https://github.com/Khan/Prototope/issues/25","id":58113978,"number":25,"title":"Prototope, Xcode, and Protocaster all crash when you forget “new” in your script","user":{"login":"jbrennan","id":131923,"avatar_url":"https://avatars.githubusercontent.com/u/131923?v=3","gravatar_id":"","url":"https://api.github.com/users/jbrennan","html_url":"https://github.com/jbrennan","followers_url":"https://api.github.com/users/jbrennan/followers","following_url":"https://api.github.com/users/jbrennan/following{/other_user}","gists_url":"https://api.github.com/users/jbrennan/gists{/gist_id}","starred_url":"https://api.github.com/users/jbrennan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbrennan/subscriptions","organizations_url":"https://api.github.com/users/jbrennan/orgs","repos_url":"https://api.github.com/users/jbrennan/repos","events_url":"https://api.github.com/users/jbrennan/events{/privacy}","received_events_url":"https://api.github.com/users/jbrennan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Khan/Prototope/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-18T19:18:27Z","updated_at":"2015-03-06T08:19:03Z","closed_at":null,"body":"This one was fun. I had the following line in my script,\r\n\r\n```\r\nvar layer = TextLayer()\r\n```\r\n\r\nAnd I couldn’t figure out what was wrong with it. Turns out I forgot `new`. Anyway, when Prototope hit that line, it crashed, and sometimes this caused Xcode to crash (betas!). Obviously the script is wrong but for some reason Prototope didn’t catch the exception...not quite sure why yet."},"comment":{"url":"https://api.github.com/repos/Khan/Prototope/issues/comments/77522256","html_url":"https://github.com/Khan/Prototope/issues/25#issuecomment-77522256","issue_url":"https://api.github.com/repos/Khan/Prototope/issues/25","id":77522256,"user":{"login":"saniul","id":371773,"avatar_url":"https://avatars.githubusercontent.com/u/371773?v=3","gravatar_id":"","url":"https://api.github.com/users/saniul","html_url":"https://github.com/saniul","followers_url":"https://api.github.com/users/saniul/followers","following_url":"https://api.github.com/users/saniul/following{/other_user}","gists_url":"https://api.github.com/users/saniul/gists{/gist_id}","starred_url":"https://api.github.com/users/saniul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saniul/subscriptions","organizations_url":"https://api.github.com/users/saniul/orgs","repos_url":"https://api.github.com/users/saniul/repos","events_url":"https://api.github.com/users/saniul/events{/privacy}","received_events_url":"https://api.github.com/users/saniul/received_events","type":"User","site_admin":false},"created_at":"2015-03-06T08:19:03Z","updated_at":"2015-03-06T08:19:03Z","body":"Investigated a bit – looks like the constructor functions that get created for the `JSExport`ed classes are generated in such a weird way that they crash JavaScriptCore when called straight, without the `new` keyword. If you look at the `JSExport.h` documentation, it actually states that those constructors aren’t \r\ncallable:\r\n\r\n![screen shot 2015-03-06 at 00 16 47](https://cloud.githubusercontent.com/assets/371773/6522154/21abb4a2-c396-11e4-9e5a-4bbaa4702125.png)\r\n\r\nThis is an actual crash (not a thrown exception) in JavaScriptCore, couldn’t figure out a workaround :( We can either live with it or stop using the constructor and expose a `create` method on all bridged types. I think just making sure we always write `new` is a better option, despite the crashiness."}}