-
Notifications
You must be signed in to change notification settings - Fork 724
Closed
Labels
a.languageRelates to the Dart language tourRelates to the Dart language tourd.enhancementImproves docs with specific askImproves docs with specific askdev.null-safetyRelates to transforming or migrating Dart code to sound null safetyRelates to transforming or migrating Dart code to sound null safetydev.type-promotionRelates to type promotion concepts and examplesRelates to type promotion concepts and examplese0-minutesCan complete in < 60 minutes of normal, not dedicated, workCan complete in < 60 minutes of normal, not dedicated, workfix.linkAdds, changes, or removes a link to a pageAdds, changes, or removes a link to a pagefrom.page-issueReported in a reader-filed concernReported in a reader-filed concernp3-lowValid but not urgent concern. Resolve when possible. Encourage upvote to surface.Valid but not urgent concern. Resolve when possible. Encourage upvote to surface.
Description
Page URL
https://dart.dev/tools/non-promotion-reasons.html
Page source
https://github.com/dart-lang/site-www/tree/master/src/tools/non-promotion-reasons.md
Describe the problem
A lot of people are confused that non-local variables aren't automatically promoted by is
or null checks. Although https://dart.dev/tools/non-promotion-reasons.html helps explain that the behavior is expected, it doesn't help readers understand the rationale for the behavior, so the inability to promote non-local variables seems arbitrary.
Expected fix
It would be useful to add a note that explains why only local variables can be promoted. Perhaps add links to dart-lang/sdk#21530, dart-lang/sdk#44327, or to https://stackoverflow.com/q/65035574/.
Additional context
No response
parlough
Metadata
Metadata
Assignees
Labels
a.languageRelates to the Dart language tourRelates to the Dart language tourd.enhancementImproves docs with specific askImproves docs with specific askdev.null-safetyRelates to transforming or migrating Dart code to sound null safetyRelates to transforming or migrating Dart code to sound null safetydev.type-promotionRelates to type promotion concepts and examplesRelates to type promotion concepts and examplese0-minutesCan complete in < 60 minutes of normal, not dedicated, workCan complete in < 60 minutes of normal, not dedicated, workfix.linkAdds, changes, or removes a link to a pageAdds, changes, or removes a link to a pagefrom.page-issueReported in a reader-filed concernReported in a reader-filed concernp3-lowValid but not urgent concern. Resolve when possible. Encourage upvote to surface.Valid but not urgent concern. Resolve when possible. Encourage upvote to surface.