From 64defc83a2614093cb2cf38ac768bfdc57183bee Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 2 Dec 2019 12:47:43 -0500 Subject: [PATCH] fix #33987, some varargs not recognized in kwarg lowering (#33992) (cherry picked from commit 2ced6c41fc3e9f18e1cca383320e1b5d3ccaa702) --- src/ast.scm | 20 +++++++++++--------- test/syntax.jl | 4 ++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/ast.scm b/src/ast.scm index b9d4ac24c19ca..7aab8d8256c5f 100644 --- a/src/ast.scm +++ b/src/ast.scm @@ -402,15 +402,17 @@ e) (define (vararg? x) (and (pair? x) (eq? (car x) '...))) -(define (varargexpr? x) (and - (pair? x) - (eq? (car x) '::) - (or - (eq? (caddr x) 'Vararg) - (and - (pair? (caddr x)) - (length> (caddr x) 1) - (eq? (cadr (caddr x)) 'Vararg))))) +(define (vararg-type-expr? x) + (or (eq? x 'Vararg) + (and (length> x 1) + (or (and (eq? (car x) 'curly) + (vararg-type-expr? (cadr x))) + (and (eq? (car x) 'where) + (vararg-type-expr? (cadr x))))))) +(define (varargexpr? x) + (and (pair? x) + (eq? (car x) '::) + (vararg-type-expr? (caddr x)))) (define (linenum? x) (and (pair? x) (eq? (car x) 'line))) (define (make-assignment l r) `(= ,l ,r)) diff --git a/test/syntax.jl b/test/syntax.jl index 50908c08ac9c4..bdf5e607f46dc 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -1943,3 +1943,7 @@ end let a(; b) = b @test a(b=3) == 3 end + +# issue #33987 +f33987(args::(Vararg{Any, N} where N); kwargs...) = args +@test f33987(1,2,3) === (1,2,3)