Skip to content

Final definite assignment #1091

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

Merged
merged 21 commits into from
Aug 19, 2020
Merged

Final definite assignment #1091

merged 21 commits into from
Aug 19, 2020

Conversation

leafpetersen
Copy link
Member

Final variant/proposal for definite assignment based inference.

This variant requires explicit initialization on all branches, but allows adjustment for Null.

@leafpetersen
Copy link
Member Author

Copy link
Member

@eernstg eernstg left a comment

Choose a reason for hiding this comment

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

LGTM. Very good, actually. ;)

@@ -433,7 +468,7 @@ Definitions:
- Else if `S` is `X extends R` then let `T1` = `X & T`
- Else If `S` is `X & R` then let `T1` = `X & T`
- Else `x` is not promotable (shouldn't happen since we checked above)
- Let `VM2 = VariableModel(declared, T1::promoted, T1::tested, assigned,
- Let `VM2 = VariableModel(declared, T1::promoted, S::tested, assigned,
Copy link
Member

Choose a reason for hiding this comment

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

Is this a deliberate change? It seems wrong--we want to add T1 to the "tested" set, since it's (effectively) the type we're testing against. S is the old type, so adding it to "tested" doesn't gain us anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, S was wrong. It's not clear to me that T1 is right though, is it? Or should it be T?

Copy link
Member

Choose a reason for hiding this comment

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

Good point. The current implementation uses T, so let's change it to that. I'm happy to do that as a separate PR if you want (since at this point it's unrelated to this change), or you can go ahead and do it now--your call.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since I backed out the rest of the changes to this doc, how about you add this change to one of your updates?

Copy link
Member

Choose a reason for hiding this comment

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

Ok, will do.

Copy link
Member

Choose a reason for hiding this comment

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

@leafpetersen
Copy link
Member Author

Removed initialization based promotion, restored var x to dynamic, and specified the behavior of initialization to null. PTAL.

Copy link
Member

@eernstg eernstg left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@stereotype441 stereotype441 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@munificent munificent left a comment

Choose a reason for hiding this comment

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

I love it. I know we went through a ton of churn to get here, but I feel pretty confident that we landed on the right answer in the end.

@leafpetersen
Copy link
Member Author

Tests out for review here: https://dart-review.googlesource.com/c/sdk/+/157881

dart-bot pushed a commit to dart-lang/sdk that referenced this pull request Aug 19, 2020
New tests for the definite assignment related changes specified in
dart-lang/language#1091 .

Change-Id: I119e36c1bddca97f7021c9015b0f2eee5cb80969
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157881
Reviewed-by: Erik Ernst <[email protected]>
Reviewed-by: Paul Berry <[email protected]>
@leafpetersen leafpetersen merged commit 2a3c615 into master Aug 19, 2020
@leafpetersen leafpetersen deleted the final_definite_assignment branch September 2, 2020 22:29
@leafpetersen
Copy link
Member Author

Tests for the initializer promotion related behavior out for review here: https://dart-review.googlesource.com/c/sdk/+/163663

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants