{"action":"opened","issue":{"url":"https://api.github.com/repos/teropa/build-your-own-angularjs/issues/293","labels_url":"https://api.github.com/repos/teropa/build-your-own-angularjs/issues/293/labels{/name}","comments_url":"https://api.github.com/repos/teropa/build-your-own-angularjs/issues/293/comments","events_url":"https://api.github.com/repos/teropa/build-your-own-angularjs/issues/293/events","html_url":"https://github.com/teropa/build-your-own-angularjs/issues/293","id":99674293,"number":293,"title":"P 236 / Method Calls: Test about fn calls with multiple arguments fails","user":{"login":"cobalamin","id":669103,"avatar_url":"https://avatars.githubusercontent.com/u/669103?v=3","gravatar_id":"","url":"https://api.github.com/users/cobalamin","html_url":"https://github.com/cobalamin","followers_url":"https://api.github.com/users/cobalamin/followers","following_url":"https://api.github.com/users/cobalamin/following{/other_user}","gists_url":"https://api.github.com/users/cobalamin/gists{/gist_id}","starred_url":"https://api.github.com/users/cobalamin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cobalamin/subscriptions","organizations_url":"https://api.github.com/users/cobalamin/orgs","repos_url":"https://api.github.com/users/cobalamin/repos","events_url":"https://api.github.com/users/cobalamin/events{/privacy}","received_events_url":"https://api.github.com/users/cobalamin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-07T15:43:45Z","updated_at":"2015-08-07T15:43:45Z","closed_at":null,"body":"I have no idea why this happens in Chrome connected to the testem server, but not in PhantomJS. But here goes:\r\n\r\nThe code `var args = _.map(ast.args, _.bind(this.recurse, this));` - from page 232 - makes for a problem where the newly introduced `ctx` (in the book itself called `context`) parameter of `this.recurse` is bound to an array index, because of the style of the [_.map iterator function](https://lodash.com/docs#map): `(value, index|key, collection)`. The line:\r\n`ctx.context = localsHasProperty + ' ?l:s';`\r\nthen fails with an error because it essentially tries to change the `context` property of the number `1`:\r\n\r\nparse functions parses a function call with multiple arguments\r\n    ✘ TypeError: Cannot assign to read only property 'context' of 1\r\n        at ASTCompiler.recurse (http://localhost:7357/src/parse.js:366:21)\r\n        at wrapper (http://localhost:7357/node_modules/lodash/index.js:3095:19)\r\n        at arrayMap (http://localhost:7357/node_modules/lodash/index.js:1406:25)\r\n        at Function.map (http://localhost:7357/node_modules/lodash/index.js:6710:14\r\n)\r\n        at ASTCompiler.recurse (http://localhost:7357/src/parse.js:403:20)\r\n        at ASTCompiler.recurse (http://localhost:7357/src/parse.js:336:44)\r\n        at ASTCompiler.compile (http://localhost:7357/src/parse.js:321:8)\r\n        at Parser.parse (http://localhost:7357/src/parse.js:468:27)\r\n        at parse (http://localhost:7357/src/parse.js:475:19)\r\n        at Object.<anonymous> (http://localhost:7357/test/parse_spec.js:1:7626)\r\n\r\nSee https://github.com/cobalamin/myangular/commit/5b7237d544b3871ae0f153325834144a20ced3f0 for the change I made to fix this: Just define another inline function that only passes the arg parameter, not the index. (Also, use _.map's own this binding mechanism as the third parameter, as it's more terse).\r\nIn the code of this repo, this style is already used, but it's not listed like this in the book."}}