From 80570616d1686e60412a8394ed7e645336c5375e Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Tue, 27 Apr 2021 15:24:31 +0900 Subject: [PATCH] REPL: fix #27184, ensure macro existence before lowering --- stdlib/REPL/src/REPLCompletions.jl | 6 ++++++ stdlib/REPL/test/replcompletions.jl | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/stdlib/REPL/src/REPLCompletions.jl b/stdlib/REPL/src/REPLCompletions.jl index fa5fd8434bec7..a55077edfe4d0 100644 --- a/stdlib/REPL/src/REPLCompletions.jl +++ b/stdlib/REPL/src/REPLCompletions.jl @@ -456,6 +456,12 @@ function get_type(sym::Expr, fn::Module) # try to analyze nests of calls. if this fails, try using the expanded form. val, found = try_get_type(sym, fn) found && return val, found + # https://github.com/JuliaLang/julia/issues/27184 + if isexpr(sym, :macrocall) + s = first(sym.args) + isa(s, Symbol) && !isdefined(fn, s) && return Any, false + isa(s, GlobalRef) && !isdefined(s.mod, s.name) && return Any, false + end return try_get_type(Meta.lower(fn, sym), fn) end diff --git a/stdlib/REPL/test/replcompletions.jl b/stdlib/REPL/test/replcompletions.jl index 8a1d2f39a18f4..9500eba2b93dc 100644 --- a/stdlib/REPL/test/replcompletions.jl +++ b/stdlib/REPL/test/replcompletions.jl @@ -1109,3 +1109,8 @@ let s = "test_dict[\"ab" c, r = test_complete_context(s) @test c == Any["\"abc\"", "\"abcd\""] end + +# https://github.com/JuliaLang/julia/issues/27184 +let s = "@noexist." + (test_complete(s); @test true) +end