Skip to content

Commit

Permalink
REPL: fix #27184, ensure macro existence before lowering (#40621)
Browse files Browse the repository at this point in the history
(cherry picked from commit b5177e7)
  • Loading branch information
aviatesk authored and staticfloat committed Dec 22, 2022
1 parent 983da63 commit f46a20a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ function get_value(sym::Expr, fn)
end
get_value(sym::Symbol, fn) = isdefined(fn, sym) ? (getfield(fn, sym), true) : (nothing, false)
get_value(sym::QuoteNode, fn) = isdefined(fn, sym.value) ? (getfield(fn, sym.value), true) : (nothing, false)
get_value(sym::GlobalRef, fn) = get_value(sym.name, sym.mod)
get_value(sym, fn) = (sym, true)

# Return the value of a getfield call expression
Expand Down Expand Up @@ -456,6 +457,11 @@ 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)
_, found = get_type(first(sym.args), fn)
found || return Any, false
end
return try_get_type(Meta.lower(fn, sym), fn)
end

Expand Down
7 changes: 7 additions & 0 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1109,3 +1109,10 @@ 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
(test_complete("@noexist."); @test true)
(test_complete("Main.@noexist."); @test true)
(test_complete("@Main.noexist."); @test true)
end

0 comments on commit f46a20a

Please sign in to comment.