Skip to content

keyword arguments don't work on left-hand side of broadcast assignments #60152

@matthias314

Description

@matthias314

Copied from this Discourse thread.

Broadcasting with assignment works with a function call on the left-hand side. However, function calls with keyword arguments do not work for some reason:

julia> f(v; a = 0) = copy(v)
f (generic function with 1 method)

julia> f([1, 2, 3]) .*= 2
3-element Vector{Int64}:
 2
 4
 6

julia> f([1, 2, 3]; a = 1) .*= 2
ERROR: syntax: invalid syntax ; (thismodule).a = 1
Stacktrace:
 [1] top-level scope
   @ REPL[3]:1

Here is what @stevengj commented on Discourse:

A similar error occurs with Julia 1.9.4, which uses the old Scheme parser, so the problem doesn’t seem specific to the new JuliaSyntax.jl. In fact, Meta.parse("f([1,2,3]; a=1) .*= 2") succeeds so it doesn’t seem to be a parser issue at all, but rather a problem in the lowering phase.

Julia Version 1.12.1
Commit ba1e628ee49 (2025-10-17 13:02 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × Intel(R) Core(TM) i3-10110U CPU @ 2.10GHz
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, skylake)

Metadata

Metadata

Assignees

No one assigned

    Labels

    broadcastApplying a function over a collectioncompiler: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