Skip to content

Fix faulty casts in checker #10560

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

Merged
merged 1 commit into from
Jun 18, 2021
Merged

Fix faulty casts in checker #10560

merged 1 commit into from
Jun 18, 2021

Conversation

hauntsaninja
Copy link
Collaborator

Fixes #9615, fixes #9682

Both issue reports hit the faulty cast on L2803. This changes the logic
so that that cast is actually always true. If not, we just end up doing
whatever the fallback else clause does; this resulted in behaviour that
matched what I expected.

After that, the #9682 hit another crash in checker.py, where var.node
was None instead of a Var. It seemed reasonable to just branch instead.

Fixes python#9615, fixes python#9682

Both issue reports hit the faulty cast on L2803. This changes the logic
so that that cast is actually always true. If not, we just end up doing
whatever the fallback else clause does; this resulted in behaviour that
matched what I expected.

After that, the python#9682 hit another crash in checker.py, where var.node
was None instead of a Var. It seemed reasonable to just branch instead.
@@ -474,3 +474,12 @@ with A() as x:
reveal_type(x) # N: Revealed type is "builtins.int"
with B() as x:
x = 0 # E: Incompatible types in assignment (expression has type "int", variable has type "str")


[case testRedefineModuleAsException]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that if you run this in real life you get:

crash.py:5: error: Incompatible types in assignment (expression has type "Exception", variable has type Module)
Found 1 error in 1 file (checked 1 source file)

I think the fixtures just aren't up to scratch here.

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for fixing these crashes.

@JukkaL JukkaL merged commit b0e36aa into python:master Jun 18, 2021
JukkaL pushed a commit that referenced this pull request Jun 21, 2021
Fixes #9615, fixes #9682

Both issue reports hit the faulty cast on L2803. This changes the logic
so that that cast is actually always true. If not, we just end up doing
whatever the fallback else clause does; this resulted in behaviour that
matched what I expected.

After that, the #9682 hit another crash in checker.py, where var.node
was None instead of a Var. It seemed reasonable to just branch instead.

Co-authored-by: hauntsaninja <>
@hauntsaninja hauntsaninja deleted the crash branch June 26, 2021 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants