This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 25590 - Off-by-one in 3.2.6 effective overload set algorithm
Off-by-one in 3.2.6 effective overload set algorithm
 Status: RESOLVED FIXED None WebAppsWG Unclassified WebIDL (show other bugs) unspecified PC Linux P2 normal --- Cameron McCormack public-webapps-bugzilla

 Reported: 2014-05-07 17:06 UTC by Joshua Bell 2017-07-30 13:24 UTC (History) 4 users (show) mike nbarth+w3bugzilla public-script-coord tobie.langel

Attachments

 Joshua Bell 2014-05-07 17:06:09 UTC ```In the "how to compute an effective overload set" algorithm: 7. While i ≥ 0: 1. If argument i of X is not optional, then break this loop. 2. Otherwise, add to S the tuple . 3. Set i to i−1. 8. If n > 0 and all arguments of X are optional, then add to S the tuple (where “()” represents the empty list). In the loop at step (7), if i == 0, then in (7.2) either the syntax is referencing negative indexes *or* this is adding to S, which is redundant with step (8). I believe this was introduced in: https://github.com/heycam/webidl/commit/97499d48855a9f9012fe145d49b83ccd71d1738b#diff-1feda49b40370635faef8b655f144f64L3228 ... where the previous version required 0 < i < n.``` Nils Barth 2014-05-08 05:36:20 UTC ```Thanks Joshua! I'm referring to: http://heycam.github.io/webidl/#dfn-effective-overload-set To fix this, there are two solutions, right? Option A: Replace: 7. While i ≥ 0: with: 7. While i > 0: Option B: Remove: 8. If n > 0 ... ...and preferably amend 5.7.2 to: 2. Otherwise, add to S the tuple ; if i is 0, this means to add to S the tuple (where “()” represents the empty list). Option A is probably simpler and more explicit spec-wise, because it avoids the negative indexes and is explicit about the bound.``` Joshua Bell 2014-05-08 16:11:03 UTC ```(In reply to Nils Barth from comment #1) > To fix this, there are two solutions, right? Yep, and I agree that A seems simpler. We might be missing some intentional subtlety, though, so I just wanted to point out the issue and let Cameron weigh in.``` Tobie Langel 2017-07-28 14:00:03 UTC `Tentative fix: https://github.com/heycam/webidl/pull/390` Tobie Langel 2017-07-30 13:24:03 UTC `Fixed in https://github.com/heycam/webidl/commit/fb40c8e`