-
Notifications
You must be signed in to change notification settings - Fork 160
Raise error on variable use before write #666
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
Conversation
bfc5758
to
5b238ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good to me, thanks for the PR!
There are a lot of test failures I can't explain easily - I wonder if you just need a rebase? I see compile errors on dataclasses
which doesn't seem to be changed here so that's my best guess
After a rebase, if you publish I could work on getting it merged
5b238ae
to
d2ee61a
Compare
Rebased and addressed your inline comments. There should be only one test failing (which is the one I linked in the PR description) |
Thanks! For the failing test case |
If it's not too inconvenient, could you fix that for me during the import? Thanks! |
This may have to wait a day or two, we have some internal infra issues and I can't import the PR right now |
d2ee61a
to
21680eb
Compare
Closes facebook#15, facebook#248 This change adds additional checks when building bindings, so that variables that are used before initialised are correctly flagged as errors. Currently, we error on uninitialised variables by checking their flow style. If the flow style is uninitialised or partially uninitialised, an error is generated. When no flow style information is obtainable (which is the case for use before write), a default "other" flow style value is returned. In this diff, we perform additional checks before returning a default "other" value. By looking up the scopes for static information for variables, we can correctly detect if a variable is declared in an upper scope or in the current scope, and return "uninitialised" flow style when the variable is used before write. When doing so, we need to consider the special case for type usages, so that name resolutions in types do not fail.
df0357f
to
9cbd480
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I'll work on getting it merged. Thanks!
Thanks a lot! @stroxler |
Closes #15, #248
This change adds additional checks when building bindings, so that
variables that are used before initialised are correctly flagged as
errors.
Currently, we error on uninitialised variables by checking their flow
style. If the flow style is uninitialised or partially uninitialised, an
error is generated. When no flow style information is obtainable (which
is the case for use before write), a default "other" flow style value is
returned.
In this diff, we perform additional checks before returning a default
"other" value. By looking up the scopes for static information for
variables, we can correctly detect if a variable is declared in an upper
scope or in the current scope, and return "uninitialised" flow style
when the variable is used before write.
When doing so, we need to consider the special case for type usages,
so that name resolutions in types do not fail.
Help needed:
There's a failing test that I need some help:
test::flow::test_assert_not_in_flow