Skip to content
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

Clarify behavior of assignedIn() for initialized variables. #1223

Merged
merged 1 commit into from
Sep 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions resources/type-system/flow-analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,18 @@ The following functions associate flow models to nodes:

- `assignedIn(S)`, where `S` is a `do`, `for`, `switch`, or `while` statement,
or a `for` element in a collection, represents the set of variables assigned
to in the recurrent part of `S`, where the "recurrent" part of `S` is defined
as:
to in the recurrent part of `S`, not counting initializations of variables at
their declaration sites. The "recurrent" part of `S` is defined as:
- If `S` is a `do` or `while` statement, the entire statement `S`.
- If `S` is a `for` statement or a `for` element in a collection, whose
`forLoopParts` take the form of a traditional for loop, all of `S` except
the `forInitializerStatement`.
- If `S` is a `for` statement or a `for` element in a collection, whose
`forLoopParts` take the form of a for-in loop, the body of `S`.
`forLoopParts` take the form of a for-in loop, the body of `S`. A loop of
the form `for (var x in ...) ...` is not considered to assign to `x`
(because `var x in ...` is considered an initialization of `x` at its
declaration site), but a loop of the form `for (x in ...) ...` (where `x` is
declared elsewhere in the function) *is* considered to assign to `x`.
- If `S` is a `switch` statement, all of `S` except the switch `expression`.

- `capturedIn(S)`, where `S` is a `do`, `for`, `switch`, or `while` statement,
Expand Down