Skip to content

Commit 9f0682d

Browse files
authored
fix #33460: better error messages on multiple semicolons in calls (#38202)
1 parent 6bea684 commit 9f0682d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/julia-syntax.scm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,8 @@
15481548
(lambda (name) (string "keyword argument \"" name
15491549
"\" repeated in call to \"" (deparse fexpr) "\""))
15501550
"keyword argument"
1551-
"keyword argument syntax"))
1551+
"keyword argument syntax"
1552+
#t))
15521553
,(if (every vararg? kw)
15531554
(kwcall-unless-empty f pa kw-container kw-container)
15541555
`(call (call (core kwfunc) ,f) ,kw-container ,f ,@pa)))))
@@ -1857,7 +1858,8 @@
18571858
(define (lower-named-tuple lst
18581859
(dup-error-fn (lambda (name) (string "field name \"" name "\" repeated in named tuple")))
18591860
(name-str "named tuple field")
1860-
(syntax-str "named tuple element"))
1861+
(syntax-str "named tuple element")
1862+
(call-with-keyword-arguments? #f))
18611863
(let* ((names (apply append
18621864
(map (lambda (x)
18631865
(cond ((symbol? x) (list x))
@@ -1926,6 +1928,8 @@
19261928
(if current
19271929
(merge current (cadr el))
19281930
`(call (top merge) (call (top NamedTuple)) ,(cadr el))))))
1931+
((and call-with-keyword-arguments? (has-parameters? L))
1932+
(error "more than one semicolon in argument list"))
19291933
(else
19301934
(error (string "invalid " syntax-str " \"" (deparse el) "\""))))))))
19311935

test/syntax.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2602,4 +2602,14 @@ end
26022602
end
26032603
end
26042604

2605+
@testset "issue #33460" begin
2606+
err = Expr(:error, "more than one semicolon in argument list")
2607+
@test Meta.lower(Main, :(f(a; b=1; c=2) = 2)) == err
2608+
@test Meta.lower(Main, :(f( ; b=1; c=2))) == err
2609+
@test Meta.lower(Main, :(f(a; b=1; c=2))) == err
2610+
@test Meta.lower(Main, :(f(a; b=1, c=2; d=3))) == err
2611+
@test Meta.lower(Main, :(f(a; b=1; c=2, d=3))) == err
2612+
@test Meta.lower(Main, :(f(a; b=1; c=2; d=3))) == err
2613+
end
2614+
26052615
@test eval(Expr(:if, Expr(:block, Expr(:&&, true, Expr(:call, :(===), 1, 1))), 1, 2)) == 1

0 commit comments

Comments
 (0)