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

ES2015 Iterator protocol impl. not complete (at least in for-of loops) #1409

Open
p-bakker opened this issue Nov 1, 2023 · 0 comments
Open
Labels
Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec
Milestone

Comments

@p-bakker
Copy link
Collaborator

p-bakker commented Nov 1, 2023

The return method is not called when breaking out or throwing inside a for-of loop

Testcase for the return method (from Compat tables):

var closed = false;
var iter = __createIterableObject([1, 2, 3], {
  'return': function(){ closed = true; return {}; }
});
for (var it of iter) break; // or throw '';
return closed;

Or with this stand-alone code, with expected output: Return called

var values = [];
var myIterator = {
  next() {
    return values.length ? {value: values.pop()}: {done: true};
  },
 return(value) { console.log('Return called'); return {done: true, value}}
};
myIterator[Symbol.iterator] = function() {return this}


for (var y of myIterator) break // or throw 1
@p-bakker p-bakker added the Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec label Nov 1, 2023
@p-bakker p-bakker added this to the ES2015 milestone Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec
Projects
None yet
Development

No branches or pull requests

1 participant