from __static__ import CheckedDict
class f():
pass
# reveal_type(f) # 'Exact[chkdict[str, int]]'
print(f["foo"])
f: CheckedDict[str, int] = CheckedDict[str, int]({'foo': 2})
What happened?
The program is type-checked and compiled, but triggers a segmentation fault at runtime.
What should have happened?
We expected two possible outcomes. But either way, the type of f shouldn't be Exact[chkdict[str, int]].
One outcome is that the program fails type checks. It is reasonable to disallow redeclaring a variable at the same scope level when the new type is not a subtype of the old type.
Another possible outcome is that Static Python catches the runtime error. In this case, the type of f should be dynamic. The local type can be type[f] and, after the redeclaration, chkdict[str, int].
bae060e 2021-10-22
What program did you run?
What happened?
The program is type-checked and compiled, but triggers a segmentation fault at runtime.
What should have happened?
We expected two possible outcomes. But either way, the type of
f
shouldn't beExact[chkdict[str, int]]
.One outcome is that the program fails type checks. It is reasonable to disallow redeclaring a variable at the same scope level when the new type is not a subtype of the old type.
Another possible outcome is that Static Python catches the runtime error. In this case, the type of
f
should bedynamic
. The local type can betype[f]
and, after the redeclaration,chkdict[str, int]
.