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

unsound typechecking for + binary operator #33

Open
bennn opened this issue Apr 20, 2017 · 0 comments
Open

unsound typechecking for + binary operator #33

bennn opened this issue Apr 20, 2017 · 0 comments

Comments

@bennn
Copy link

bennn commented Apr 20, 2017

If a variable X refers to a function in "module scope" and an integer in "function body scope", then the expression 1 + X will report a type error saying X has function type.

The expression X + 1 works fine.

Same things happen with the * binary operator.

Here's an example. The variable z is bound to a function in "module scope" and to an integer within the body of the function f. On the line marked ERROR, the typechecker (unsoundly) believes that z has type Function([], Int)

def z ()->int:
  return 0

def f()->int:
  z = 4
  y = z + 1 # OK
  x = 1 + z # ERROR
  return 0

Error message:

====STATIC TYPE ERROR=====
bar.py:7:6: Int and Function([], Int) are invalid operand types for the binary operator +. (code BINOP_INCOMPAT)
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