Skip to content

Commit

Permalink
fix #23236 (#23243)
Browse files Browse the repository at this point in the history
comprehension eta-reduction needs to know that dot operators are not
function names.

(cherry picked from commit 37655e3)
  • Loading branch information
JeffBezanson authored and ararslan committed Sep 18, 2017
1 parent bd22138 commit dc83959
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,7 @@
(if (and (null? splat)
(length= expr 3) (eq? (car expr) 'call)
(eq? (caddr expr) argname)
(not (dotop? (cadr expr)))
(not (expr-contains-eq argname (cadr expr))))
(cadr expr) ;; eta reduce `x->f(x)` => `f`
`(-> ,argname (block ,@splat ,expr)))))
Expand Down
5 changes: 5 additions & 0 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ let x = [1:4;]
@test sin.(f17300kw.(x, y=1)) == sin.(f17300kw.(x; y=1)) == sin.(x .+ 1)
end

# issue #23236
let X = [[true,false],[false,true]]
@test [.!x for x in X] == [[false,true],[true,false]]
end

# splice escaping of @.
let x = [4, -9, 1, -16]
@test [2, 3, 4, 5] == @.(1 + sqrt($sort(abs(x))))
Expand Down

0 comments on commit dc83959

Please sign in to comment.