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
AllType is a Type, and its type parameters are strings:
params: list[str]
GenericVar is a Type, referencing a type parameter, a string:
id: str
In the substitute_type function, the keys of the var_map dictionary seem to be type parameters names (strings, str), and the values seem to be types (Type).
However, in match_types function, in the AllType case, the var_map passed to substitute_type seems to construct a dictionary mapping type parameter names (str) to type parameter names (str), not types:
Shouldn't the values be wrapped in GenericVar, i.e.
rename= {ap: GenericVar(p) for (ap,p) inzip(arg_ps, ps)}
That is also what is done in the check_type_equal function, in the AllTypes case:
rename= {p2: GenericVar(p1) for (p1,p2) inzip(ps1,ps2)}
Great work and thank you for the fantastic book!
The text was updated successfully, but these errors were encountered:
turbolent
changed the title
Questions for and potential issue in Generics section of Python book
Potential bug in Generics section of Python book
Nov 25, 2024
There might be a bug in the
TypeCheckLgeneric
.AllType
is aType
, and its type parameters are strings:GenericVar
is aType
, referencing a type parameter, a string:In the
substitute_type
function, the keys of thevar_map
dictionary seem to be type parameters names (strings,str
), and the values seem to be types (Type
).However, in
match_types
function, in theAllType
case, thevar_map
passed tosubstitute_type
seems to construct a dictionary mapping type parameter names (str
) to type parameter names (str
), not types:Shouldn't the values be wrapped in
GenericVar
, i.e.That is also what is done in the
check_type_equal
function, in theAllTypes
case:Great work and thank you for the fantastic book!
The text was updated successfully, but these errors were encountered: