You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use List;
class C {
iter foo() throws {
for i in1..10doyield i;
}
}
class D: C {
overrideiter foo() throws {
for i in1..10doyield2*i;
}
}
var l =new list(shared C?);
l.pushBack(newshared C());
l.pushBack(newshared 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.
The text was updated successfully, but these errors were encountered:
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
fromC.foo()
, you get an internal compiler error. It looks likethrows
is part of aproc
'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.The text was updated successfully, but these errors were encountered: