parenthesized assignment is easy to miss in an elif clause especially:
if (cond:
pass
elif (x = 5): # did we mean assignment or did we mistype == but thought the elif syntax required parentheses like C?
pass
)
should be
if (cond:
pass
elif x := 5:
pass
)
We should probably still keep the notion that assignment in a call e.g. foo(x=5) is a Call with a NamedParameter (even though there are a few issues with the current implementation) but we should require foo(x := 5) rather than foo((x = 5)) for an assignment expression in a call (regardless of the C++ unspecified order of evaluation gotcha with these).
Note: forget if we attempt to ban assignments in non-special (e.g. not "if" calls) already - there is some brokenness and hacks related to the handling of extra parentheses in if call args currently due to later parser changes.
parenthesized assignment is easy to miss in an elif clause especially:
should be
We should probably still keep the notion that assignment in a call e.g. foo(x=5) is a Call with a NamedParameter (even though there are a few issues with the current implementation) but we should require foo(x := 5) rather than foo((x = 5)) for an assignment expression in a call (regardless of the C++ unspecified order of evaluation gotcha with these).
Note: forget if we attempt to ban assignments in non-special (e.g. not "if" calls) already - there is some brokenness and hacks related to the handling of extra parentheses in if call args currently due to later parser changes.