Skip to content

[REPLCompletions] allow symbol completions within incomplete macrocall expression #51834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
12 changes: 12 additions & 0 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down