Add links to explain behavior on 'Fixing type promotion failures' page #3744
Labels
a.language
Relates to the Dart language tour
d.enhancement
Improves docs with specific ask
dev.null-safety
Relates to transforming or migrating Dart code to sound null safety
dev.type-promotion
Relates to type promotion concepts and examples
e0-minutes
Can complete in < 60 minutes of normal, not dedicated, work
fix.link
Adds, changes, or removes a link to a page
from.page-issue
Reported in a reader-filed concern
p3-low
Valid but not urgent concern. Resolve when possible. Encourage upvote to surface.
st.triage.ltw
Indicates Lead Tech Writer has triaged
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
The text was updated successfully, but these errors were encountered: