-
Notifications
You must be signed in to change notification settings - Fork 1
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
Unwind functions don't propagate from WHILE condition block #1519
Comments
Submitted by: Ladislav in the core-tests suite |
Submitted by: BrianH Weird: I was expecting QUIT and HALT to be caught by this as well, but they aren't, and not by #1760 either. |
Submitted by: BrianH Expanded the tests for this in core-tests. As of alpha 111, BREAK and CONTINUE apparently work in the condition block, but the other unwinds aren't passed through. Doesn't work in R2 either, but it's a bug there too. |
I don't think the highest value for CONTINUE or BREAK in a condition of a WHILE is to have that WHILE process it. Reasons:
A recent change to Red made it illegal to use BREAK or CONTINUE in a WHILE's condition. That is probably clearest, in terms of "principle of least surprise", since it keeps one from having to worry over the semantics of whether continue runs the condition again or not. But what seems most useful is just to not consider the condition to be a slot where BREAK or CONTINUE would be handled any differently. So it would be assumed to refer to some enclosing loop construct. This unambiguous interpretation is based on the idea that a while's body is a kind of context for a new BREAK or CONTINUE to arise...the condition is separate. So that's the strategy used in Ren-C. |
Submitted by: BrianH
The unwind functions: RETURN, EXIT, BREAK, CONTINUE, THROW.
The unwinding process doesn't propagate from within the WHILE condition block because WHILE doesn't return the unwind values from there (or any values for that matter). If WHILE could check for unwind values returned from the condition block then it could act on BREAK and CONTINUE, or return the rest from the function so they can propagate. As it is now in R3, WHILE treats the unwind value like an untriggered error! and considers it true, which often leads to an endless loop.
This is related to bug #1509, but that refers to function argument processing by DO, while this refers to WHILE.
Note that the behavior of R2 should not be emulated: It is also in error, but a different error.
CC - Data [ Version: alpha 97 Type: Bug Platform: All Category: Error Handling Reproduce: Always Fixed-in:r3 master ]
The text was updated successfully, but these errors were encountered: