diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 623474353f580..819b56d7d0d6b 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -227,10 +227,8 @@ (define (method-expr-name m) (let ((name (cadr m))) - (let ((name (if (or (length= m 2) (not (pair? name)) (not (quoted? name))) name (cadr name)))) - (cond ((not (pair? name)) name) - ((eq? (car name) 'globalref) (caddr name)) - (else name))))) + (cond ((globalref? name) (caddr name)) + (else name)))) ;; extract static parameter names from a (method ...) expression (define (method-expr-static-parameters m) @@ -4087,7 +4085,7 @@ f(x) = yt(x) (newlam (compact-and-renumber (linearize (car exprs)) 'none 0))) `(toplevel-butfirst (block ,@sp-inits - (method ,name ,(cl-convert sig fname lam namemap defined toplevel interp opaq globals locals) + (method ,(cadr e) ,(cl-convert sig fname lam namemap defined toplevel interp opaq globals locals) ,(julia-bq-macro newlam))) ,@top-stmts)))) diff --git a/test/syntax.jl b/test/syntax.jl index f92eb071415cc..3acf5864b2614 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -3845,3 +3845,16 @@ struct SingletonMaker; end const no_really_this_is_a_function_i_promise = Val{SingletonMaker()}() no_really_this_is_a_function_i_promise(a) = 2 + a @test Val{SingletonMaker()}()(2) == 4 + +# Test that lowering doesn't accidentally put a `Module` in the Method name slot +let src = @Meta.lower let capture=1 + global foo_lower_block + foo_lower_block() = capture +end + code = src.args[1].code + for i = length(code):-1:1 + expr = code[i] + Meta.isexpr(expr, :method) || continue + @test isa(expr.args[1], Union{GlobalRef, Symbol}) + end +end