Skip to content

Update conditional expression section of IDA#4472

Merged
RikkiGibson merged 8 commits intodotnet:masterfrom
RikkiGibson:ida-ternary-spec
Mar 1, 2021
Merged

Update conditional expression section of IDA#4472
RikkiGibson merged 8 commits intodotnet:masterfrom
RikkiGibson:ida-ternary-spec

Conversation

@RikkiGibson
Copy link
Member

Builds on #4468

This handles the `dict?.TryGetValue(key, out var value) ?? false` scenario, by taking the resulting state of a "hypothetical" `dict.TryGetValue(key, out var value)` call and using it as the resulting state-when-true of the `dict?.TryGetValue(key, out var value) ?? false` expression.
The above rule formalizes that for an expression like `a?.M(out x) ?? (x = false)`, either the `a?.M(out x)` was fully evaluated and produced a non-null value, in which case `x` was assigned, or the `x = false` was evaluated, in which case `x` was also assigned. Therefore `x` is always assigned after this expression.

This also handles the `dict?.TryGetValue(key, out var value) ?? false` scenario, by observing that *v* is definitely assigned after `dict.TryGetValue(key, out var value)`, and *v* is "definitely assigned when true" after `false`, and concluding that *v* must be "definitely assigned when true".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice :-)

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks (iteration 8)

@jcouv jcouv self-assigned this Mar 1, 2021
@RikkiGibson RikkiGibson merged commit 5a537b3 into dotnet:master Mar 1, 2021
@RikkiGibson RikkiGibson deleted the ida-ternary-spec branch March 1, 2021 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants