{"action":"closed","issue":{"url":"https://api.github.com/repos/wgreenberg/quine.zip/issues/3","labels_url":"https://api.github.com/repos/wgreenberg/quine.zip/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/wgreenberg/quine.zip/issues/3/comments","events_url":"https://api.github.com/repos/wgreenberg/quine.zip/issues/3/events","html_url":"https://github.com/wgreenberg/quine.zip/issues/3","id":96726657,"number":3,"title":"Cannot read property 'length' of undefined","user":{"login":"shaheenp","id":7840252,"avatar_url":"https://avatars.githubusercontent.com/u/7840252?v=3","gravatar_id":"","url":"https://api.github.com/users/shaheenp","html_url":"https://github.com/shaheenp","followers_url":"https://api.github.com/users/shaheenp/followers","following_url":"https://api.github.com/users/shaheenp/following{/other_user}","gists_url":"https://api.github.com/users/shaheenp/gists{/gist_id}","starred_url":"https://api.github.com/users/shaheenp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shaheenp/subscriptions","organizations_url":"https://api.github.com/users/shaheenp/orgs","repos_url":"https://api.github.com/users/shaheenp/repos","events_url":"https://api.github.com/users/shaheenp/events{/privacy}","received_events_url":"https://api.github.com/users/shaheenp/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-23T04:38:08Z","updated_at":"2015-07-24T00:49:23Z","closed_at":"2015-07-24T00:49:23Z","body":"This bug occurs when a repeat command is executed with N = 0 (e.g. `repeat 1 0`).\r\n\r\nIt occurs on [src/interpreter.js#L81](https://github.com/wgreenberg/quine.zip/blob/gh-pages/src/interpreter.js#L81). In [this code block](https://github.com/wgreenberg/quine.zip/blob/gh-pages/src/interpreter.js#L97), `start` ends up equaling 1 because `outputLines` is an array of 1 item and `instructions.b` is 0. Because `start` is 1, the loop is accessing `outputLines[1]`, which is `undefined` because `outputLines` has only 1 item, but the value still gets pushed to `outputLines`. `program` at that point is an empty array, so [src/interpreter#L90](https://github.com/wgreenberg/quine.zip/blob/gh-pages/src/interpreter.js#L90) gets executed. Remember that `outputLines` is an array of `[/*previous action {String}*/, undefined]`. Now we're back at [src/interpreter.js#L81](https://github.com/wgreenberg/quine.zip/blob/gh-pages/src/interpreter.js#L81), where `undefined.length` throws the error.\r\n\r\nHopefully that made sense...\r\nHere are some examples that throw the error:\r\n```js\r\nprint 1\r\nprint 1\r\nrepeat 1 0\r\n\r\n// OR\r\n\r\nprint 2\r\nprint 1\r\nprint 1\r\nrepeat 3 0\r\n\r\n// OR\r\n\r\nprint 1\r\nprint 3\r\nrepeat 2 0\r\nprint 2\r\n```"}}