Skip to content

Commit

Permalink
[1/2] Fix creation of TypeVarType.
Browse files Browse the repository at this point in the history
We weren't actually passing in the variance, instead
we were passing in line as the value and letting line
get defaulted.

As a possible fix for things like this not happening
in the future, invariance really should be an enum,
not an int. Otherwise, we don't get protected by the
type system we are making...
  • Loading branch information
jhance committed Oct 9, 2015
1 parent bc0323e commit a98cc74
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mypy/typeanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ def visit_unbound_type(self, t: UnboundType) -> Type:
if len(t.args) > 0:
self.fail('Type variable "{}" used with arguments'.format(
t.name), t)
values = cast(TypeVarExpr, sym.node).values
return TypeVarType(t.name, sym.tvar_id, values,
tvar_expr = cast(TypeVarExpr, sym.node)
return TypeVarType(t.name, sym.tvar_id, tvar_expr.values,
self.builtin_type('builtins.object'),
tvar_expr.variance,
t.line)
elif fullname == 'builtins.None':
return Void()
Expand Down

0 comments on commit a98cc74

Please sign in to comment.