Commit 3baf2bfd authored by Stefan Behnel's avatar Stefan Behnel

minor fix and extension to type inference for builtin type operations

parent a59eab52
......@@ -4766,10 +4766,12 @@ class BinopNode(ExprNode):
return type1
# multiplication of containers/numbers with an
# integer value always (?) returns the same type
if type1.is_int:
return type2
elif type2.is_int:
if type2.is_int:
return type1
elif type2.is_builtin_type and type1.is_int and self.operator == '*':
# multiplication of containers/numbers with an
# integer value always (?) returns the same type
return type2
return py_object_type
else:
return self.compute_c_result_type(type1, type2)
......
......@@ -104,10 +104,12 @@ def builtin_type_operations():
>>> builtin_type_operations()
"""
b1 = b'a' * 10
b1 = 10 * b'a'
assert typeof(b1) == "bytes object", typeof(b1)
b2 = b'a' + b'b'
assert typeof(b2) == "bytes object", typeof(b2)
u1 = u'a' * 10
u1 = 10 * u'a'
assert typeof(u1) == "unicode object", typeof(u1)
u2 = u'a' + u'b'
assert typeof(u2) == "unicode object", typeof(u2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment