Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a sequence from an iterable: IteratorClose not called #895

Open
bathos opened this issue Jun 17, 2020 · 0 comments
Open

Creating a sequence from an iterable: IteratorClose not called #895

bathos opened this issue Jun 17, 2020 · 0 comments

Comments

@bathos
Copy link
Contributor

bathos commented Jun 17, 2020

In Creating a sequence from an iterable, step 3.4. is Initialize Si to the result of converting nextItem to an IDL value of type T. This step can throw. That isn’t addressed with either ? (ReturnIfAbrupt shorthand) or express handling. I’m not sure if that omission is an error itself or if Web IDL allows for implicit abrupt-completion-bubbling.

If conversion throws, I’d expect IteratorClose to get called. The absence of iterator closing in the conversion algorithm can be observed when, for example, finally blocks don’t get evaluated:

document.createElement('canvas').getContext('2d').setLineDash(function * () {
  try {
    yield Symbol(); // will fail to coerce to unrestricted double, throwing a TypeError
  } finally {
    console.log('iterator closed'); // return() isn’t called; this statement isn’t evaluated
  }
}());

When the above is evaluated in Chrome or Firefox, the iterator isn’t closed. Safari however does perform iterator closing if member conversion fails — the finally block does get evaluated. Although that’s a departure from the Web IDL spec currently, I think that should be the specified behavior.

The Array.from builtin may be instructive because in the usingIterator path, if you ignore the bits that are specific to assembling an ES array, it’s pretty much the same premise as create-a-sequence-from-an-iterable (where mapFn is the Web IDL “convert” step which might throw).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant