From 3b1ba62bd27e0dabbd2ec0a6c000edb8138c5915 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:45:45 +0900 Subject: [PATCH] [REPLCompletions] allow symbol completions within incomplete macrocall expression (#51834) fix #51827 --------- Co-authored-by: Kristoffer Carlsson --- stdlib/REPL/src/REPLCompletions.jl | 5 +++++ stdlib/REPL/test/replcompletions.jl | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/stdlib/REPL/src/REPLCompletions.jl b/stdlib/REPL/src/REPLCompletions.jl index 6eb12c71dcb07..290a26ea4f6f3 100644 --- a/stdlib/REPL/src/REPLCompletions.jl +++ b/stdlib/REPL/src/REPLCompletions.jl @@ -1053,6 +1053,11 @@ function complete_identifiers!(suggestions::Vector{Completion}, @nospecialize(ff if isinfix ex = ex.args[end] end + elseif isexpr(ex, :macrocall) && length(ex.args) > 1 + # allow symbol completions within potentially incomplete macrocalls + if s[end] ≠ '`' && s[end] ≠ ')' + ex = ex.args[end] + end end end append!(suggestions, complete_symbol(ex, name, ffunc, context_module)) diff --git a/stdlib/REPL/test/replcompletions.jl b/stdlib/REPL/test/replcompletions.jl index 28b3ef5de2ed7..9f174f4be51ac 100644 --- a/stdlib/REPL/test/replcompletions.jl +++ b/stdlib/REPL/test/replcompletions.jl @@ -2085,6 +2085,18 @@ for (s, compl) in (("2*CompletionFoo.nam", "named"), @test only(c) == compl end +# allows symbol completion within incomplete :macrocall +# https://github.com/JuliaLang/julia/issues/51827 +macro issue51827(args...) + length(args) ≥ 2 || error("@issue51827: incomplete arguments") + return args +end +let s = "@issue51827 Base.ac" + c, r, res = test_complete_context(s) + @test res + @test "acquire" in c +end + let t = REPLCompletions.repl_eval_ex(:(`a b`), @__MODULE__; limit_aggressive_inference=true) @test t isa Core.Const @test t.val == `a b`