From 0b5d5d62b184fb9f720fa91d67eb819f17ca27ba Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 26 Sep 2016 13:36:08 -0400 Subject: [PATCH] fix #18672, `function f end` in some macro expansions --- src/macroexpand.scm | 6 +++--- test/core.jl | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/macroexpand.scm b/src/macroexpand.scm index 471e9bf6f13b0..991b3da6ab06d 100644 --- a/src/macroexpand.scm +++ b/src/macroexpand.scm @@ -347,9 +347,9 @@ ;; pick up only function name (let ((fname (cond ((eq? (car e) '=) (cadr (cadr e))) ((eq? (car e) 'function) - (if (eq? (car (cadr e)) 'tuple) - #f - (cadr (cadr e)))) + (cond ((atom? (cadr e)) (cadr e)) + ((eq? (car (cadr e)) 'tuple) #f) + (else (cadr (cadr e))))) (else #f)))) (if (symbol? fname) (list fname) diff --git a/test/core.jl b/test/core.jl index a52ed478ba2bc..5ea3d51b9c3c8 100644 --- a/test/core.jl +++ b/test/core.jl @@ -3610,6 +3610,17 @@ end @test TestMacroGlobalFunction.ff(1) == 2 @test TestMacroGlobalFunction.gg(1) == 3 +# issue #18672 +macro x18672() + quote + function f + end + end +end +let + @test isa(@x18672, Function) +end + # issue #14564 @test isa(object_id(Tuple.name.cache), Integer)