Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ast.scm
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
(check-dotop (cadr e))))))
e)

(define (vararg? x) (and (pair? x) (eq? (car x) '...)))
(define (vararg? x) (and (pair? x) (eq? (car x) '...) (length= x 2)))
(define (vararg-type-expr? x)
(or (eq? x 'Vararg)
(and (length> x 1)
Expand Down
8 changes: 5 additions & 3 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2691,8 +2691,7 @@
(if (null? run) '()
(list `(call (core tuple) ,.(reverse run))))
(let ((x (car a)))
(if (and (length= x 2)
(eq? (car x) '...))
(if (vararg? x)
(if (null? run)
(list* (cadr x)
(tuple-wrap (cdr a) '()))
Expand Down Expand Up @@ -2814,7 +2813,10 @@
'.>>>= lower-update-op

'|...|
(lambda (e) (error "\"...\" expression outside call"))
(lambda (e)
(if (not (length= e 2))
(error "wrong number of expressions following \"...\""))
(error "\"...\" expression outside call"))

'$
(lambda (e) (error "\"$\" expression outside quote"))
Expand Down
9 changes: 9 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ end
# issue #15828
@test Meta.lower(Main, Meta.parse("x...")) == Expr(:error, "\"...\" expression outside call")

# issue #57153 - malformed "..." expr
module M57153
macro foo()
Expr(:(...), 1, 2, 3)
end
end
@test Meta.lower(M57153, :(identity(@foo()))) ==
(Expr(:error, "wrong number of expressions following \"...\""))

# issue #15830
@test Meta.lower(Main, Meta.parse("foo(y = (global x)) = y")) == Expr(:error, "misplaced \"global\" declaration")

Expand Down