Commit 0a28c907 authored by Ian Henriksen's avatar Ian Henriksen

Fixed special case for assignment overloading in cascaded assignment where

all left hand sides have the same type.
parent e77db9c9
......@@ -5088,8 +5088,14 @@ class CascadedAssignmentNode(AssignmentNode):
lhs_types.add(lhs.type)
rhs = self.rhs.analyse_types(env)
if len(lhs_types) == 1:
# common special case: only one type needed on the LHS => coerce only once
if len(lhs_types) == 1:
# Avoid coercion for overloaded assignment operators.
if next(iter(lhs_types)).is_cpp_class:
op = env.lookup_operator('=', [lhs, self.rhs])
if not op:
rhs = rhs.coerce_to(lhs_types.pop(), env)
else:
rhs = rhs.coerce_to(lhs_types.pop(), env)
if not rhs.is_name and not rhs.is_literal and (
......
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