-
Notifications
You must be signed in to change notification settings - Fork 441
Open
Labels
Description
The following program compiles and runs, but the exception thrown by the second iter these cannot be caught.
record R {
iter these(start) throws {
var x = start;
while true {
yield x;
if x == 0 {
break;
}
throw new Error();
x -= 1;
}
}
iter these() throws {
for e in this.these(10) do yield e;
}
}
proc main() {
var r = new R();
try {
for i in r.these(5) {
writeln(i);
}
} catch e {
writeln("Caught Exception: ", e); // this print works, the exception can be caught
}
try {
for i in r {
writeln(i);
}
} catch e {
writeln("Caught Exception: ", e); // this print never is called, the exception cannot be caught
}
}
This program results in the following output
5
Caught Exception: Error:
10
uncaught Error:
bug.chpl:33: thrown here
bug.chpl:33: uncaught here
This is maybe not that surprising, considering Chapel's limited support for throwing iterators. See #15089, #7134, and #26478