-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Lambdas are accepted by the type checker but not actually checked #2
Labels
bug
mypy got something wrong
Comments
ghost
assigned JukkaL
Dec 12, 2012
Implemented bidirectional type inference for lambdas. It works correctly in common cases but it still fails if you give sufficiently tricky code. |
ichard26
added a commit
to ichard26/mypy
that referenced
this issue
Mar 17, 2023
Change how imports (not from imports!) are processed so they can be table-driven and compact. Here's how it works: Import nodes are divided in groups (in the prebuild visitor). Each group consists of consecutive Import nodes: import mod <| group python#1 import mod2 | def foo() -> None: import mod3 <- group python#2 import mod4 <- group python#3 Every time we encounter the first import of a group, build IR to call CPyImport_ImportMany() that will perform all of the group's imports in one go. Previously, each module would imported and placed in globals manually in IR, leading to some pretty verbose code. The other option to collect all imports and perform them all at once in the helper would remove even more ops, however, it's problematic for the same reasons from the previous commit (spoiler: it's not safe). Implementation notes: - I had to add support for loading the address of a static directly, so I shoehorned in LoadLiteral support for LoadAddress. - Unfortunately by replacing multiple nodes with a single function call at the IR level, the traceback line number is static. Even if an import several lines down a group fails, the line # of the first import in the group would be printed. To fix this, I had to make CPyImport_ImportMany() add the traceback entry itself on failure (instead of letting codegen handle it automatically). This is admittedly ugly.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use lambdas in code, but the type checker basically ignores them and always gives them the 'any' type.
Code like this is accepted, which is obviously wrong:
The text was updated successfully, but these errors were encountered: