Skip to content

Disallow multiple LHS assignment for one-line function definitions #46517

@StephenVavasis

Description

@StephenVavasis

Should one-line function definitions be allowed in multiple-LHS assignment statements? Julia (1.7.1) is inconsistent on this matter as the example below shows. My own opinion is that it should not be allowed, because there are too many weird corner cases if it is allowed.

julia> f(x),g(x)=3,5;

julia> f(12) + g('a')
8

julia> f(x),g(x)=x*x,x*x*x
ERROR: UndefVarError: x not defined
Stacktrace:
 [1] top-level scope
   @ REPL[22]:1

This issue was initially raised in discourse by Angel_Ramirez_Reyes: https://discourse.julialang.org/t/why-is-this-a-malformed-expression/86391/6

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:loweringSyntax lowering (compiler front end, 2nd stage)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions