{"action":"created","issue":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/250","labels_url":"https://api.github.com/repos/ocaml/ocaml/issues/250/labels{/name}","comments_url":"https://api.github.com/repos/ocaml/ocaml/issues/250/comments","events_url":"https://api.github.com/repos/ocaml/ocaml/issues/250/events","html_url":"https://github.com/ocaml/ocaml/pull/250","id":108877832,"number":250,"title":"Check for negative start element in Array.sub","user":{"login":"yallop","id":1736496,"avatar_url":"https://avatars.githubusercontent.com/u/1736496?v=3","gravatar_id":"","url":"https://api.github.com/users/yallop","html_url":"https://github.com/yallop","followers_url":"https://api.github.com/users/yallop/followers","following_url":"https://api.github.com/users/yallop/following{/other_user}","gists_url":"https://api.github.com/users/yallop/gists{/gist_id}","starred_url":"https://api.github.com/users/yallop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yallop/subscriptions","organizations_url":"https://api.github.com/users/yallop/orgs","repos_url":"https://api.github.com/users/yallop/repos","events_url":"https://api.github.com/users/yallop/events{/privacy}","received_events_url":"https://api.github.com/users/yallop/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-09-29T14:10:03Z","updated_at":"2015-09-29T14:51:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ocaml/ocaml/pulls/250","html_url":"https://github.com/ocaml/ocaml/pull/250","diff_url":"https://github.com/ocaml/ocaml/pull/250.diff","patch_url":"https://github.com/ocaml/ocaml/pull/250.patch"},"body":"Before:\r\n\r\n```ocaml\r\n# Array.sub [|0;1|] (-1) 1;;\r\n- : int array = [|1408|]\r\n# Array.sub [|0;1|] (-1000000) 1000000;;\r\nSegmentation fault\r\n```\r\n\r\nAfter:\r\n\r\n```ocaml\r\n# Array.sub [|0;1|] (-1) 1;;\r\nException: Invalid_argument \"Array.sub\".\r\n# Array.sub [|0;1|] (-1000000) 1000000;;\r\nException: Invalid_argument \"Array.sub\".\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/comments/144084355","html_url":"https://github.com/ocaml/ocaml/pull/250#issuecomment-144084355","issue_url":"https://api.github.com/repos/ocaml/ocaml/issues/250","id":144084355,"user":{"login":"dbuenzli","id":485596,"avatar_url":"https://avatars.githubusercontent.com/u/485596?v=3","gravatar_id":"","url":"https://api.github.com/users/dbuenzli","html_url":"https://github.com/dbuenzli","followers_url":"https://api.github.com/users/dbuenzli/followers","following_url":"https://api.github.com/users/dbuenzli/following{/other_user}","gists_url":"https://api.github.com/users/dbuenzli/gists{/gist_id}","starred_url":"https://api.github.com/users/dbuenzli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbuenzli/subscriptions","organizations_url":"https://api.github.com/users/dbuenzli/orgs","repos_url":"https://api.github.com/users/dbuenzli/repos","events_url":"https://api.github.com/users/dbuenzli/events{/privacy}","received_events_url":"https://api.github.com/users/dbuenzli/received_events","type":"User","site_admin":false},"created_at":"2015-09-29T14:51:31Z","updated_at":"2015-09-29T14:51:31Z","body":"> @dbuenzli we always have the same problem that this would risk breaking old code that matches against a string literal in an exception.\r\n\r\nThat's a problem with your philosophy, this old code deserves to be broken. Code that relies on matching string literal in exceptions shouldn't be trusted. `Invalid_argument` is not supposed to be catched on its literal argument, it means: programming error, discard the whole processing block or even abort the program.\r\n\r\nThe only place where catching `Invalid_argument` precisely could be justified is around code that uses `bool_of_string`, which for mysterious reasons doesn't raise `Failure` but `Invalid_argument`. But then if you never change the string returned by `bool_of_string` this should not be a problem. \r\n\r\n\r\n"}}