Skip to content

Conversation

@simeonschaub
Copy link
Member

Discovered while working on #40737. Currently, this throws an
unintuitive error:

julia> a, f()... = 1, 2, 3
ERROR: syntax: ssavalue with no def
Stacktrace:
 [1] top-level scope
   @ REPL[1]:1

Might as well fix this properly - Why not allow function definitions to
slurp a little from time to time? ;)

Discovered while working on #40737. Currently, this throws an
unintuitive error:
```julia
julia> a, f()... = 1, 2, 3
ERROR: syntax: ssavalue with no def
Stacktrace:
 [1] top-level scope
   @ REPL[1]:1
```

Might as well fix this properly - Why not allow function definitions to
slurp a little from time to time? ;)
@simeonschaub simeonschaub added the compiler:lowering Syntax lowering (compiler front end, 2nd stage) label May 6, 2021
@simeonschaub simeonschaub requested a review from JeffBezanson May 6, 2021 21:41
@simeonschaub
Copy link
Member Author

Not claiming it's necessarily all that useful, but I think this is pretty cool at least:

julia> x = [1, 2, 3];

julia> _, f()... = x;

julia> f()
2-element Vector{Int64}:
 2
 3

julia> x[3] = 4;

julia> f()
2-element Vector{Int64}:
 2
 4

@simeonschaub
Copy link
Member Author

Bump.

@simeonschaub simeonschaub added the merge me PR is reviewed. Merge when all tests are passing label Jun 30, 2021
@vtjnash vtjnash removed the merge me PR is reviewed. Merge when all tests are passing label Jul 1, 2021
@vtjnash
Copy link
Member

vtjnash commented Jul 1, 2021

Seems unhappy with some merge conflict?

@simeonschaub
Copy link
Member Author

Might be related to #40737, will look into it.

@simeonschaub
Copy link
Member Author

Yes, the example linked above now doesn't close over x anymore, but instead the call to Base.rest now happens outside of f's body. I think with #40737 merged, this is actually the behavior we want.

@simeonschaub simeonschaub merged commit 5c49a0d into master Jul 2, 2021
@simeonschaub simeonschaub deleted the sds/slurp_fdef branch July 2, 2021 00:01
johanmon pushed a commit to johanmon/julia that referenced this pull request Jul 5, 2021
Discovered while working on JuliaLang#40737. Currently, this throws an
unintuitive error:
```julia
julia> a, f()... = 1, 2, 3
ERROR: syntax: ssavalue with no def
Stacktrace:
 [1] top-level scope
   @ REPL[1]:1
```

Might as well fix this properly - Why not allow function definitions to
slurp a little from time to time? ;)
KristofferC pushed a commit that referenced this pull request Jul 7, 2021
Discovered while working on #40737. Currently, this throws an
unintuitive error:
```julia
julia> a, f()... = 1, 2, 3
ERROR: syntax: ssavalue with no def
Stacktrace:
 [1] top-level scope
   @ REPL[1]:1
```

Might as well fix this properly - Why not allow function definitions to
slurp a little from time to time? ;)

(cherry picked from commit 5c49a0d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants