Skip to content

Should have := expression assign like python instead of parenthese (e.g. (x = y) vs x = y) to indicate an expression assign in a Call vs a named parameter #1

@ehren

Description

@ehren

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions