Skip to content

Commit b5177e7

Browse files
authored
REPL: fix #27184, ensure macro existence before lowering (#40621)
1 parent e4fcdf5 commit b5177e7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

stdlib/REPL/src/REPLCompletions.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ function get_value(sym::Expr, fn)
384384
end
385385
get_value(sym::Symbol, fn) = isdefined(fn, sym) ? (getfield(fn, sym), true) : (nothing, false)
386386
get_value(sym::QuoteNode, fn) = isdefined(fn, sym.value) ? (getfield(fn, sym.value), true) : (nothing, false)
387+
get_value(sym::GlobalRef, fn) = get_value(sym.name, sym.mod)
387388
get_value(sym, fn) = (sym, true)
388389

389390
# Return the value of a getfield call expression
@@ -456,6 +457,11 @@ function get_type(sym::Expr, fn::Module)
456457
# try to analyze nests of calls. if this fails, try using the expanded form.
457458
val, found = try_get_type(sym, fn)
458459
found && return val, found
460+
# https://github.com/JuliaLang/julia/issues/27184
461+
if isexpr(sym, :macrocall)
462+
_, found = get_type(first(sym.args), fn)
463+
found || return Any, false
464+
end
459465
return try_get_type(Meta.lower(fn, sym), fn)
460466
end
461467

stdlib/REPL/test/replcompletions.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,3 +1113,10 @@ let s = "test_dict[\"ab"
11131113
c, r = test_complete_context(s)
11141114
@test c == Any["\"abc\"", "\"abcd\""]
11151115
end
1116+
1117+
# https://github.com/JuliaLang/julia/issues/27184
1118+
let
1119+
(test_complete("@noexist."); @test true)
1120+
(test_complete("Main.@noexist."); @test true)
1121+
(test_complete("@Main.noexist."); @test true)
1122+
end

0 commit comments

Comments
 (0)