-
Notifications
You must be signed in to change notification settings - Fork 28
#3057. Add more try-catch-finally tests #3146
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I think, however, that a few cases are expected to pass, but must be errors.
if (s is T) {} | ||
} catch (_) { | ||
(s,) = (T(),); | ||
s.answer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this one to fail because before(S0) = conservativeJoin(before(N), ...)
, where T
is not a type of interest for s
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But according to the dart-lang/sdk#60519 this should be an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, it should be an error because T
is not a type of interest for s
at the location of the pattern assignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I just created dart-lang/language#4328 in order to clarify the situation: The implemented behavior appears to be different from the specified behavior.
if (s is T) {} | ||
} catch (_) { | ||
(s,) = (T(),); | ||
s.answer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect this to fail because each alternative starts with before(N)
(plus some assigned
and some captured
bits, but they won't change anything about types of interest).
s.answer(); | ||
} finally { | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we should certainly test try/catch/finally even though it's not yet in the spec. Best effort, as usual. ;-)
But I guess they'd fit better in a series of tests named reachability_try_catch_finally_A*_t*.dart
.
if (s is T) {} | ||
} catch (_) { | ||
(s,) = (T(),); | ||
s.answer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should again fail, considering that the catch blocks have no more than before(N)
when it comes to types of interest.
} catch (_) { | ||
} finally { | ||
(x: s) = (x: T()); | ||
s.answer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
/// - Let `after(N) = restrict(after(B1), after(B2), assignedIn(B2))` | ||
/// | ||
/// @description Checks that if a type `T` is made a type of interest in a catch | ||
/// part of `B1` then it can be promoted in `B1`, `B2` and `after(N)`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think B1
can include a catch part. I think we have rules about try .. catch .. catch
and about try .. finally
, but the rule about try .. catch .. catch .. finally
is missing.
So we're testing try
-catch
-finally
statements as a separate kind of case, noting that these tests must be revisited when the spec rule is in place.
if (s is T) {} | ||
} catch (_) { | ||
(s,) = (T(),); | ||
s.answer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should fail, S0
is not a predecessor of S1
in the flow graph.
if (s is T) {} | ||
} finally { | ||
(x: s) = (x: T()); | ||
s.answer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, the catch
block is not a predecessor of the finally
block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Clarifications)
if (s is T) {} | ||
} catch (_) { | ||
(s,) = (T(),); | ||
s.answer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, it should be an error because T
is not a type of interest for s
at the location of the pattern assignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one might need to be blocked on a spec clarification, too: dart-lang/language#4328.
if (s is T) {} | ||
} catch (_) { | ||
(s,) = (T(),); | ||
s.answer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I just created dart-lang/language#4328 in order to clarify the situation: The implemented behavior appears to be different from the specified behavior.
Partially tests are duplicates of existing ones, partially replaced by #3148. Closing this one. |
No description provided.