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
# optional_refine_and.py# This should pass.# This should terminate.fromtypingimportOptionaldefexpect_int(i: int) ->None:
returndeff(x: Optional[int]) ->None:
returnxandexpect_int(x)
assertf(None) isNoneassertf(42) isNone
What happened?
return x and expect_int(x)
^
compiler.errors.TypedSyntaxError: return type must be None, not Optional[int]
What should have happened?
The program should be accepted by the type checker.
# optional_refine_or.py# This should fail.fromtypingimportOptionaldefexpect_int(i: int) ->int:
return42deff(x: Optional[int]) ->int:
returnxorexpect_int(x)
[root@0fcdc5077884 vol]# ./python -m compiler --static Playground/conformance_suite/optional_refine_or.py
Traceback (most recent call last):
....
File "Playground/conformance_suite/optional_refine_or.py", line 10
return x or expect_int(x)
^
compiler.errors.TypedSyntaxError: type mismatch: None received for positional arg 'i', expected int
[root@0fcdc5077884 vol]#
The text was updated successfully, but these errors were encountered:
a4a71ae
2021-12-29
What program did you run?
What happened?
What should have happened?
The program should be accepted by the type checker.
Note that a dual test fails as expected.
The text was updated successfully, but these errors were encountered: