{"action":"created","issue":{"url":"https://api.github.com/repos/jstolarek/slicer/issues/63","repository_url":"https://api.github.com/repos/jstolarek/slicer","labels_url":"https://api.github.com/repos/jstolarek/slicer/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/jstolarek/slicer/issues/63/comments","events_url":"https://api.github.com/repos/jstolarek/slicer/issues/63/events","html_url":"https://github.com/jstolarek/slicer/issues/63","id":210615839,"number":63,"title":"Possible bug: Store invariants broken?","user":{"login":"jstolarek","id":1597921,"avatar_url":"https://avatars.githubusercontent.com/u/1597921?v=3","gravatar_id":"","url":"https://api.github.com/users/jstolarek","html_url":"https://github.com/jstolarek","followers_url":"https://api.github.com/users/jstolarek/followers","following_url":"https://api.github.com/users/jstolarek/following{/other_user}","gists_url":"https://api.github.com/users/jstolarek/gists{/gist_id}","starred_url":"https://api.github.com/users/jstolarek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jstolarek/subscriptions","organizations_url":"https://api.github.com/users/jstolarek/orgs","repos_url":"https://api.github.com/users/jstolarek/repos","events_url":"https://api.github.com/users/jstolarek/events{/privacy}","received_events_url":"https://api.github.com/users/jstolarek/received_events","type":"User","site_admin":false},"labels":[{"id":511487746,"url":"https://api.github.com/repos/jstolarek/slicer/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-02-27T21:43:48Z","updated_at":"2017-02-27T22:28:51Z","closed_at":null,"body":"The implementation of the `Store` logic might have a bug introduced by implementation of arrays:\r\n\r\n```\r\nStore { \r\n  { refs :: M.IntMap Value\r\n  , arrs :: M.IntMap Array,\r\n  , refCount :: Int\r\n```\r\n(Field names added for clarity.) The intention of `refCount` is to track the number of allocated references. So the invariant should be `M.Size refs = refCount`. This is invalidated by `storeCreateArr`:\r\n\r\n```haskell\r\nstoreCreateArr :: Store -> Int -> Value -> (Store, StoreLabel)\r\nstoreCreateArr (Store refs arrs refCount) dim v =\r\n    (Store refs (M.insert refCount (mkArray dim v) arrs) (refCount + 1),\r\n     StoreLabel refCount)\r\n```\r\nSo now the invariant is `M.Size refs + M.size arrs = refCount` and keys in `refs` and `arrs` are not consecutive integers.\r\n\r\nI'm not sure if this causes any problems - needs deeper investigation."},"comment":{"url":"https://api.github.com/repos/jstolarek/slicer/issues/comments/282877509","html_url":"https://github.com/jstolarek/slicer/issues/63#issuecomment-282877509","issue_url":"https://api.github.com/repos/jstolarek/slicer/issues/63","id":282877509,"user":{"login":"jstolarek","id":1597921,"avatar_url":"https://avatars.githubusercontent.com/u/1597921?v=3","gravatar_id":"","url":"https://api.github.com/users/jstolarek","html_url":"https://github.com/jstolarek","followers_url":"https://api.github.com/users/jstolarek/followers","following_url":"https://api.github.com/users/jstolarek/following{/other_user}","gists_url":"https://api.github.com/users/jstolarek/gists{/gist_id}","starred_url":"https://api.github.com/users/jstolarek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jstolarek/subscriptions","organizations_url":"https://api.github.com/users/jstolarek/orgs","repos_url":"https://api.github.com/users/jstolarek/repos","events_url":"https://api.github.com/users/jstolarek/events{/privacy}","received_events_url":"https://api.github.com/users/jstolarek/received_events","type":"User","site_admin":false},"created_at":"2017-02-27T22:28:51Z","updated_at":"2017-02-27T22:28:51Z","body":"Indeed, I think this is no longer needed in the current code. This was definitely required at some point in the past, but I think this invariant might have become obsolete when I refactored `Store` to be abstract outside of `Core` module. I definitely want to take a closer look at this later to make sure this is indeed correct."}}
{"actor":{"display_login":"jstolarek"}}