You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
If a variable
X
refers to a function in "module scope" and an integer in "function body scope", then the expression1 + X
will report a type error sayingX
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 functionf
. On the line markedERROR
, the typechecker (unsoundly) believes thatz
has typeFunction([], Int)
Error message:
The text was updated successfully, but these errors were encountered: