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

Fix type guards propagating invisibile bindings #1782

Merged
merged 1 commit into from
Oct 7, 2024
Merged

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Sep 24, 2024

Fix type guards propagating invisibile bindings

The test case test_only_use_visible_bindings added in this change fails with the following error before the fix:

dummy_input_file:7:9: error: in <module>: Name 'value' is not defined [name-error]

  Variable value has been used after it has been deleted (line 4).

  print(value)
        ~~~~~

This happens because the "Deleted" binding, which is not visible anymore after the value = 2 assignment, is made visible again by the type guard.

The fix: rather than operating on all bindings and making them visible, we now only operate on visible bindings.

While testing my changes I broke existing code in 2 different ways and added new test cases for these. The tests test_dont_hide_previous_bindings and test_type_guard_matches_input_type pass before this change and still pass after it.

PiperOrigin-RevId: 683162424
@copybara-service copybara-service bot merged commit a01851f into main Oct 7, 2024
1 check passed
@copybara-service copybara-service bot deleted the cl/678135913 branch October 7, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant