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

typechecking of closures is bogus #10

Open
AndrewTolmach opened this issue Dec 20, 2022 · 0 comments
Open

typechecking of closures is bogus #10

AndrewTolmach opened this issue Dec 20, 2022 · 0 comments

Comments

@AndrewTolmach
Copy link
Contributor

Currently, type_check_Llambda.py treats the type of a closure as being the type of the corresponding tuple. But this makes it impossible to obtain type equality for two lambdas that have closures with different shapes. Indeed, it is well-known that type-checking closure-converted code requires existential types.

This problem has been masked partly because the test suite doesn't contain any triggers, and partly because type_check_Ltup.py currently fails to compare tuples properly (it doesn't check that they have the same length).

A test file that demonstrates the problem is:

def p() -> Callable[[int], int]:
    b = True
    x = 42
    f : Callable[[int], int] = lambda z: z if b else 1
    g : Callable[[int], int] = lambda w: w if x == 42 else 1
    return f if True else g
print(p()(42))
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

No branches or pull requests

1 participant