-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
The spec doesn't lay out the precise rules for variable scoping. I didn't find any surprises but I still had to discover them by experimentation. This is what I gathered:
- lexical block scoping for functions, methods, if/case/for/while etc
- a new variable defined in a if/case/for/while does not outlive the block even if it has the same name and type in all branches
- you can't use let to re-define an existing variable, even if it was made in an outer scope (no shadowing)
- if a linear variable is borrowed in a
borrowblock, it vanishes for the duration of the borrow block then reappears afterwards
Is this a fair description?
oh also the let-destructure section doesn't talk about the optional as fragment.
Metadata
Metadata
Assignees
Labels
No labels