Skip to content

Commit

Permalink
fix #26916, anon fn syntax with 1 kw and 1 optional arg (#26970)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed May 4, 2018
1 parent 6f50774 commit ee2211c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1969,11 +1969,9 @@
(cond ((eq? (car e) 'tuple) (map =-to-kw (cdr e)))
((eq? (car e) 'block)
(cond ((length= e 1) '())
((length= e 2) (list (cadr e)))
((length= e 2) (list (=-to-kw (cadr e))))
((length= e 3)
(if (assignment? (caddr e))
`((parameters (kw ,@(cdr (caddr e)))) ,(cadr e))
`((parameters ,(caddr e)) ,(cadr e))))
`((parameters ,(=-to-kw (caddr e))) ,(=-to-kw (cadr e))))
(else
(error "more than one semicolon in argument list"))))
(else
Expand Down
11 changes: 11 additions & 0 deletions test/keywordargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,14 @@ end
@test_throws UndefKeywordError g(1)
@test_throws UndefKeywordError g(1, z=2)
end

@testset "issue #26916 - anonymous function with 1 keyword arg and 1 optional arg" begin
f = (x=1;y=2)->(x,y)
@test f() == (1,2)
@test f(10) == (10,2)
@test f(y=20) == (1,20)
@test f(20, y=30) == (20,30)
g = (x=1;)->(x,x)
@test g() == (1,1)
@test g(2) == (2,2)
end

2 comments on commit ee2211c

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.