Skip to content

Commit

Permalink
fix JuliaLang#33460: better error messages on multiple semicolons in …
Browse files Browse the repository at this point in the history
…calls (JuliaLang#38202)
  • Loading branch information
belamenso authored Nov 10, 2020
1 parent 6bea684 commit 9f0682d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,8 @@
(lambda (name) (string "keyword argument \"" name
"\" repeated in call to \"" (deparse fexpr) "\""))
"keyword argument"
"keyword argument syntax"))
"keyword argument syntax"
#t))
,(if (every vararg? kw)
(kwcall-unless-empty f pa kw-container kw-container)
`(call (call (core kwfunc) ,f) ,kw-container ,f ,@pa)))))
Expand Down Expand Up @@ -1857,7 +1858,8 @@
(define (lower-named-tuple lst
(dup-error-fn (lambda (name) (string "field name \"" name "\" repeated in named tuple")))
(name-str "named tuple field")
(syntax-str "named tuple element"))
(syntax-str "named tuple element")
(call-with-keyword-arguments? #f))
(let* ((names (apply append
(map (lambda (x)
(cond ((symbol? x) (list x))
Expand Down Expand Up @@ -1926,6 +1928,8 @@
(if current
(merge current (cadr el))
`(call (top merge) (call (top NamedTuple)) ,(cadr el))))))
((and call-with-keyword-arguments? (has-parameters? L))
(error "more than one semicolon in argument list"))
(else
(error (string "invalid " syntax-str " \"" (deparse el) "\""))))))))

Expand Down
10 changes: 10 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2602,4 +2602,14 @@ end
end
end

@testset "issue #33460" begin
err = Expr(:error, "more than one semicolon in argument list")
@test Meta.lower(Main, :(f(a; b=1; c=2) = 2)) == err
@test Meta.lower(Main, :(f( ; b=1; c=2))) == err
@test Meta.lower(Main, :(f(a; b=1; c=2))) == err
@test Meta.lower(Main, :(f(a; b=1, c=2; d=3))) == err
@test Meta.lower(Main, :(f(a; b=1; c=2, d=3))) == err
@test Meta.lower(Main, :(f(a; b=1; c=2; d=3))) == err
end

@test eval(Expr(:if, Expr(:block, Expr(:&&, true, Expr(:call, :(===), 1, 1))), 1, 2)) == 1

0 comments on commit 9f0682d

Please sign in to comment.