{"action":"created","issue":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/9557","repository_url":"https://api.github.com/repos/nim-lang/Nim","labels_url":"https://api.github.com/repos/nim-lang/Nim/issues/9557/labels{/name}","comments_url":"https://api.github.com/repos/nim-lang/Nim/issues/9557/comments","events_url":"https://api.github.com/repos/nim-lang/Nim/issues/9557/events","html_url":"https://github.com/nim-lang/Nim/issues/9557","id":375074937,"node_id":"MDU6SXNzdWUzNzUwNzQ5Mzc=","number":9557,"title":"strutils.multiReplace() crashes if search string is \"\"","user":{"login":"genotrance","id":192231,"node_id":"MDQ6VXNlcjE5MjIzMQ==","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":[{"id":101971351,"node_id":"MDU6TGFiZWwxMDE5NzEzNTE=","url":"https://api.github.com/repos/nim-lang/Nim/labels/Stdlib","name":"Stdlib","color":"eb6420","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2018-10-29T15:31:03Z","updated_at":"2018-11-01T19:04:42Z","closed_at":"2018-10-31T16:13:03Z","author_association":"CONTRIBUTOR","body":"```nim\r\nimport strutils\r\nvar\r\n  search = \"\"\r\n  replacement = \"abc\"\r\necho \"string\".multiReplace(search, replacement)\r\n# EDIT(@timotheecour ) I think this should be: `echo \"string\".multiReplace((\"\", \"abc\"))`\r\n```\r\n\r\nCrash output\r\n```\r\nstrutils.nim             multiReplace\r\nSIGSEGV: Illegal storage access. (Attempt to read from nil?)\r\n```\r\n\r\nThis works on 0.18.0 but fails on 0.19.0 and #head."},"comment":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/comments/435150736","html_url":"https://github.com/nim-lang/Nim/issues/9557#issuecomment-435150736","issue_url":"https://api.github.com/repos/nim-lang/Nim/issues/9557","id":435150736,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTE1MDczNg==","user":{"login":"timotheecour","id":2194784,"node_id":"MDQ6VXNlcjIxOTQ3ODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/2194784?v=4","gravatar_id":"","url":"https://api.github.com/users/timotheecour","html_url":"https://github.com/timotheecour","followers_url":"https://api.github.com/users/timotheecour/followers","following_url":"https://api.github.com/users/timotheecour/following{/other_user}","gists_url":"https://api.github.com/users/timotheecour/gists{/gist_id}","starred_url":"https://api.github.com/users/timotheecour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timotheecour/subscriptions","organizations_url":"https://api.github.com/users/timotheecour/orgs","repos_url":"https://api.github.com/users/timotheecour/repos","events_url":"https://api.github.com/users/timotheecour/events{/privacy}","received_events_url":"https://api.github.com/users/timotheecour/received_events","type":"User","site_admin":false},"created_at":"2018-11-01T19:04:42Z","updated_at":"2018-11-01T19:04:42Z","author_association":"COLLABORATOR","body":"/cc @Araq \r\n> We don't throw on API usage bugs, we could have used doAssert \r\n\r\nhuh? see https://github.com/nim-lang/Nim/pull/9280 and your comment (https://github.com/nim-lang/Nim/pull/9280#issuecomment-428840784) in pretty much the same context (for ``count`` on empty string)\r\n> This should instead use assert or doAssert, it's an API misuse.\r\n\r\n> but that makes people nervous who value \"continue\" over \"crash and burn\".\r\n\r\nwhich is why I suggested in https://github.com/nim-lang/Nim/pull/9280#issuecomment-428786497 (as well as here) to throw (by that I mean a recoverable exception) instead of `doAssert` \r\nMy suggestion is to simply throw `CatchableError` (or perhaps `ValueError` but I like the simplicity of using the root of catchable errors) \r\nThat's not `crash and burn`, that's normal exception handling mechanism ; it can peacefully coexist inside a production-server-that-can-never-die\r\n\r\n"}}
{"actor":{"display_login":"timotheecour"}}