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

Internal and/or misleading error messages around throwing / virtual-dispatched iterators #26478

Open
e-kayrakli opened this issue Jan 7, 2025 · 0 comments

Comments

@e-kayrakli
Copy link
Contributor

use List;

class C {
  iter foo() throws {
    for i in 1..10 do yield i;
  }
}

class D: C {
  override iter foo() throws  {
    for i in 1..10 do yield 2*i;
  }
}

var l = new list(shared C?);

l.pushBack(new shared C());
l.pushBack(new shared D());

for item in l {
  for x in item!.foo() {
    writeln(x);
  }
}

Above, I have a simple class hierarchy with an overridden iterator. If I want to make these iterators throw, I get error: throwing non-inlined iterators are not yet supported. Where my guess is that these are not inlined because they are virtually dispatched. The error message isn't very helpful. We can simply blanket prohibit throwing overridden iterators.


As a related issue, if you remove throws from C.foo(), you get an internal compiler error. It looks like throws is part of a proc's interface when it is overridden (if parent's throws, children's must throw, too). And failure to do that is reflected with a nice error message. We should have the same for the iterator case.

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

No branches or pull requests

1 participant