https://github.com/JuliaLang/julia
Revision b3f766c2005acb9b3859b04f357de90355f38325 authored by Keno Fischer on 18 July 2023, 21:40:21 UTC, committed by GitHub on 18 July 2023, 21:40:21 UTC
Pop quiz: Do you know what the following will do?
```
julia> function g1(a=(1,2)..., b...=3)
    b
end

julia> g1()

julia> function g2(a=(1,2)..., b=3, c=4)
    (b, c)
end

julia> g2()

julia> function g3(a=(1,2)..., b=3, c...=4)
    (b, c)
end

julia> g3()

julia> g3(1)
```

I don't either and I don't think it's particularly well defined.
Splatting a default argument makes sense on the last argument, which can
be a vararg, and it is desirable to be able to specify the default for
the whole varargs tuple at once (although arguably that should just be
the non-`...` behavior, but that'd be too breaking a change). Ref
#50518. However, for other arguments, there isn't really a sensible
semantic meaning. This PR disallows this in lowering. This is
technically a minor change, but I doubt anybody is using this. Splatting
in default values wasn't really ever supposed to work anyway, it just
happened to fall out of our lowering.

---------

Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
1 parent d270a71
History
Tip revision: b3f766c2005acb9b3859b04f357de90355f38325 authored by Keno Fischer on 18 July 2023, 21:40:21 UTC
lowering: Disallow splatting in non-final default value (#50563)
Tip revision: b3f766c
File Mode Size
.devcontainer
.github
base
cli
contrib
deps
doc
etc
src
stdlib
test
.buildkite-external-version -rw-r--r-- 5 bytes
.clang-format -rw-r--r-- 3.3 KB
.clangd -rw-r--r-- 114 bytes
.codecov.yml -rw-r--r-- 52 bytes
.git-blame-ignore-revs -rw-r--r-- 371 bytes
.gitattributes -rw-r--r-- 65 bytes
.gitignore -rw-r--r-- 523 bytes
.mailmap -rw-r--r-- 12.7 KB
CITATION.bib -rw-r--r-- 513 bytes
CITATION.cff -rw-r--r-- 940 bytes
CONTRIBUTING.md -rw-r--r-- 23.4 KB
HISTORY.md -rw-r--r-- 370.0 KB
LICENSE.md -rw-r--r-- 1.3 KB
Make.inc -rw-r--r-- 55.3 KB
Makefile -rw-r--r-- 30.1 KB
NEWS.md -rw-r--r-- 1.1 KB
README.md -rw-r--r-- 7.3 KB
THIRDPARTY.md -rw-r--r-- 3.8 KB
VERSION -rw-r--r-- 11 bytes
julia.spdx.json -rw-r--r-- 35.8 KB
pkgimage.mk -rw-r--r-- 6.0 KB
sysimage.mk -rw-r--r-- 4.3 KB

README.md

back to top