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,9 +5088,15 @@ class CascadedAssignmentNode(AssignmentNode): ...@@ -5088,9 +5088,15 @@ class CascadedAssignmentNode(AssignmentNode):
lhs_types.add(lhs.type) lhs_types.add(lhs.type)
rhs = self.rhs.analyse_types(env) rhs = self.rhs.analyse_types(env)
# common special case: only one type needed on the LHS => coerce only once
if len(lhs_types) == 1: if len(lhs_types) == 1:
# common special case: only one type needed on the LHS => coerce only once # Avoid coercion for overloaded assignment operators.
rhs = rhs.coerce_to(lhs_types.pop(), env) 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 ( if not rhs.is_name and not rhs.is_literal and (
use_temp or rhs.is_attribute or rhs.type.is_pyobject): use_temp or rhs.is_attribute or rhs.type.is_pyobject):
......
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