{"action":"created","issue":{"url":"https://api.github.com/repos/MiniZinc/libminizinc/issues/43","labels_url":"https://api.github.com/repos/MiniZinc/libminizinc/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/MiniZinc/libminizinc/issues/43/comments","events_url":"https://api.github.com/repos/MiniZinc/libminizinc/issues/43/events","html_url":"https://github.com/MiniZinc/libminizinc/issues/43","id":102814168,"number":43,"title":"Out-of-bounds error in \"then\" branch goes undetected","user":{"login":"informarte","id":13946903,"avatar_url":"https://avatars.githubusercontent.com/u/13946903?v=3","gravatar_id":"","url":"https://api.github.com/users/informarte","html_url":"https://github.com/informarte","followers_url":"https://api.github.com/users/informarte/followers","following_url":"https://api.github.com/users/informarte/following{/other_user}","gists_url":"https://api.github.com/users/informarte/gists{/gist_id}","starred_url":"https://api.github.com/users/informarte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/informarte/subscriptions","organizations_url":"https://api.github.com/users/informarte/orgs","repos_url":"https://api.github.com/users/informarte/repos","events_url":"https://api.github.com/users/informarte/events{/privacy}","received_events_url":"https://api.github.com/users/informarte/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-24T15:05:26Z","updated_at":"2015-08-26T07:38:54Z","closed_at":null,"body":"int: M = 2;\r\nint: N = 3;\r\narray[1..M] of var 1..N: length; % **We consider M tours of maximum length N**\r\narray[1..M, 1..N] of var int: places; % **Only places[i, j] with j <= length[i] are valid**\r\n\r\n% **In the valid part of places[i], adjacent places must be different**\r\nconstraint\r\n    forall(i in 1..M, j in 1..N-1) (\r\n        if j < length[i] then places[i, j] != places[i, j + 1] else true endif\r\n    );\r\n\r\n% **Same constraint as above except for undetected out-of-bounds error (\"j - 1\" instead of \"j + 1\")**\r\nconstraint\r\n    forall(i in 1..M, j in 1..N-1) (\r\n        if j < length[i] then places[i, j] != places[i, j - 1] else true endif\r\n    );\r\n\r\n% **Now without if/then/endif: Out-of-bounds error is detected properly**\r\nconstraint\r\n    forall(i in 1..M, j in 1..N-1) (\r\n        places[i, j] != places[i, j - 1]\r\n    );\r\n\r\n\r\nsolve satisfy;\r\n"},"comment":{"url":"https://api.github.com/repos/MiniZinc/libminizinc/issues/comments/134879446","html_url":"https://github.com/MiniZinc/libminizinc/issues/43#issuecomment-134879446","issue_url":"https://api.github.com/repos/MiniZinc/libminizinc/issues/43","id":134879446,"user":{"login":"informarte","id":13946903,"avatar_url":"https://avatars.githubusercontent.com/u/13946903?v=3","gravatar_id":"","url":"https://api.github.com/users/informarte","html_url":"https://github.com/informarte","followers_url":"https://api.github.com/users/informarte/followers","following_url":"https://api.github.com/users/informarte/following{/other_user}","gists_url":"https://api.github.com/users/informarte/gists{/gist_id}","starred_url":"https://api.github.com/users/informarte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/informarte/subscriptions","organizations_url":"https://api.github.com/users/informarte/orgs","repos_url":"https://api.github.com/users/informarte/repos","events_url":"https://api.github.com/users/informarte/events{/privacy}","received_events_url":"https://api.github.com/users/informarte/received_events","type":"User","site_admin":false},"created_at":"2015-08-26T07:38:54Z","updated_at":"2015-08-26T07:38:54Z","body":"Section 10.3 (Partial Array Access) of the MiniZinc 2.0 spec distinguishes two cases for array indices: fixed and unfixed values. Your statement pertains to unfixed array values. For fixed array values a run-time error is required.\r\n\r\nInterestingly, when I rewrite the constraint as follows, flattening aborts as expected:\r\n\r\n```\r\nconstraint\r\n    forall(i in 1..M, j in 1..N-1) (\r\n        let {var bool: c = j < length[i]; var bool: t = places[i, j] != places[i, j - 1]} in c -> t\r\n    );\r\n```\r\n\r\n\r\n\r\n"}}