{"action":"created","issue":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/7335","repository_url":"https://api.github.com/repos/nim-lang/Nim","labels_url":"https://api.github.com/repos/nim-lang/Nim/issues/7335/labels{/name}","comments_url":"https://api.github.com/repos/nim-lang/Nim/issues/7335/comments","events_url":"https://api.github.com/repos/nim-lang/Nim/issues/7335/events","html_url":"https://github.com/nim-lang/Nim/issues/7335","id":305263998,"number":7335,"title":"Bad error message when writing to a data structure within read-only object","user":{"login":"genotrance","id":192231,"avatar_url":"https://avatars0.githubusercontent.com/u/192231?v=4","gravatar_id":"","url":"https://api.github.com/users/genotrance","html_url":"https://github.com/genotrance","followers_url":"https://api.github.com/users/genotrance/followers","following_url":"https://api.github.com/users/genotrance/following{/other_user}","gists_url":"https://api.github.com/users/genotrance/gists{/gist_id}","starred_url":"https://api.github.com/users/genotrance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genotrance/subscriptions","organizations_url":"https://api.github.com/users/genotrance/orgs","repos_url":"https://api.github.com/users/genotrance/repos","events_url":"https://api.github.com/users/genotrance/events{/privacy}","received_events_url":"https://api.github.com/users/genotrance/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-14T17:47:47Z","updated_at":"2018-03-14T17:59:50Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"```nim\r\nimport sets\r\n\r\ntype\r\n  parent = object\r\n    hash: HashSet[string]\r\n\r\nproc getParent(): parent =\r\n  result.hash.init()\r\n\r\nlet a = getParent()\r\na.hash.incl(\"Hello\")\r\n```\r\nHere `a` is read-only so Nim should tell you that. Instead you see the following error which is hard to figure out.\r\n```\r\nctest.nim(11, 7) Error: type mismatch: got <HashSet[system.string], string>\r\nbut expected one of:\r\nproc incl[T](x: var set[T]; y: T)\r\n  first type mismatch at position: 1\r\n  required type: var set[T]\r\n  but expression 'a.hash' is of type: HashSet[system.string]\r\ntemplate incl[T](s: var set[T]; flags: set[T])\r\n  first type mismatch at position: 1\r\n  required type: var set[T]\r\n  but expression 'a.hash' is of type: HashSet[system.string]\r\nproc incl[A](s: var HashSet[A]; key: A)\r\n  first type mismatch at position: 1\r\n  required type: var HashSet[incl.A]\r\n  but expression 'a.hash' is of type: HashSet[system.string]\r\nproc incl[A](s: var HashSet[A]; other: OrderedSet[A])\r\n  first type mismatch at position: 1\r\n  required type: var HashSet[incl.A]\r\n  but expression 'a.hash' is of type: HashSet[system.string]\r\nproc incl[A](s: var OrderedSet[A]; key: A)\r\n  first type mismatch at position: 1\r\n  required type: var OrderedSet[incl.A]\r\n  but expression 'a.hash' is of type: HashSet[system.string]\r\nproc incl[A](s: var HashSet[A]; other: HashSet[A])\r\n  first type mismatch at position: 1\r\n  required type: var HashSet[incl.A]\r\n  but expression 'a.hash' is of type: HashSet[system.string]\r\n\r\nexpression: incl(a.hash, \"Hello\")\r\n```"},"comment":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/comments/373118279","html_url":"https://github.com/nim-lang/Nim/issues/7335#issuecomment-373118279","issue_url":"https://api.github.com/repos/nim-lang/Nim/issues/7335","id":373118279,"user":{"login":"genotrance","id":192231,"avatar_url":"https://avatars0.githubusercontent.com/u/192231?v=4","gravatar_id":"","url":"https://api.github.com/users/genotrance","html_url":"https://github.com/genotrance","followers_url":"https://api.github.com/users/genotrance/followers","following_url":"https://api.github.com/users/genotrance/following{/other_user}","gists_url":"https://api.github.com/users/genotrance/gists{/gist_id}","starred_url":"https://api.github.com/users/genotrance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genotrance/subscriptions","organizations_url":"https://api.github.com/users/genotrance/orgs","repos_url":"https://api.github.com/users/genotrance/repos","events_url":"https://api.github.com/users/genotrance/events{/privacy}","received_events_url":"https://api.github.com/users/genotrance/received_events","type":"User","site_admin":false},"created_at":"2018-03-14T17:59:50Z","updated_at":"2018-03-14T17:59:50Z","author_association":"CONTRIBUTOR","body":"Feedback on IRC from [Araq](https://irclogs.nim-lang.org/13-03-2018.html#22:51:09)."}}
{"actor":{"display_login":"genotrance"}}