Skip to content
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

[REPLCompletions] suppress false positive field completions #51502

Merged
merged 1 commit into from
Sep 30, 2023

Conversation

aviatesk
Copy link
Member

Field completions can be wrong when getproperty and propertynames are overloaded for a target object type, since a custom getproperty does not necessarily accept field names. This commit simply suppresses field completions in such cases. Fixes the second part of #51499.

Field completions can be wrong when `getproperty` and `propertynames`
are overloaded for a target object type, since a custom `getproperty`
does not necessarily accept field names. This commit simply suppresses
field completions in such cases. Fixes the second part of #51499.
aviatesk added a commit that referenced this pull request Sep 29, 2023
The REPL completion engine employs aggressive inference (incorporating
aggressive global binding resolution and aggressive concrete evaluation,
ignoring `:consistent`-cy), enabling completions in scenarios such as:
```julia
julia> d = Dict{Symbol,Any}(:key => Any[Some(r"x")])

julia> d[:key][1].value.<TAB>

compile_options
match_options
pattern
regex
```

While this approach has proven to be quite effective, it has its
limitations, given that aggressive inference was only activated for the
top-level representing an input code. Therefore, it fails to apply to
general cases like:
```julia
julia> getkeyelem(d) = d[:key][1]

julia> getkeyelem(d).<TAB> # no TAB completion
```

This limitation is the underlying cause of the first part of #51499.

To rectify this, the commit implements the following:
1. generalizes aggressive inference to apply to all child frames,
   when they are not cached.
2. enables aggressive constant propagation, allowing the propagation of
   mutable Consts.

With these changes, now we can get:
```julia
julia> getkeyelem(d). # TAB completes

julia> getkeyelem(d).value.

compile_options
match_options
pattern
regex
```

In conjunction with #51502, this resolves #51499.
@aviatesk aviatesk merged commit d988f8f into master Sep 30, 2023
@aviatesk aviatesk deleted the avi/51499-2 branch September 30, 2023 06:44
aviatesk added a commit that referenced this pull request Sep 30, 2023
The REPL completion engine employs aggressive inference (incorporating
aggressive global binding resolution and aggressive concrete evaluation,
ignoring `:consistent`-cy), enabling completions in scenarios such as:
```julia
julia> d = Dict{Symbol,Any}(:key => Any[Some(r"x")])

julia> d[:key][1].value.<TAB>

compile_options
match_options
pattern
regex
```

While this approach has proven to be quite effective, it has its
limitations, given that aggressive inference was only activated for the
top-level representing an input code. Therefore, it fails to apply to
general cases like:
```julia
julia> getkeyelem(d) = d[:key][1]

julia> getkeyelem(d).<TAB> # no TAB completion
```

This limitation is the underlying cause of the first part of #51499.

To rectify this, the commit implements the following:
1. generalizes aggressive inference to apply to all child frames,
   when they are not cached.
2. enables aggressive constant propagation, allowing the propagation of
   mutable Consts.

With these changes, now we can get:
```julia
julia> getkeyelem(d). # TAB completes

julia> getkeyelem(d).value.

compile_options
match_options
pattern
regex
```

In conjunction with #51502, this resolves #51499.
vtjnash pushed a commit that referenced this pull request Sep 30, 2023
…es (#51503)

The REPL completion engine employs aggressive inference (incorporating
aggressive global binding resolution and aggressive concrete evaluation,
ignoring `:consistent`-cy), enabling completions in scenarios such as:
```julia
julia> d = Dict{Symbol,Any}(:key => Any[Some(r"x")])

julia> d[:key][1].value.<TAB>

compile_options
match_options
pattern
regex
```

While this approach has proven to be quite effective, it has its
limitations, given that aggressive inference was only activated for the
top-level representing an input code. Therefore, it fails to apply to
general cases like:
```julia
julia> getkeyelem(d) = d[:key][1]

julia> getkeyelem(d).<TAB> # no TAB completion
```

This limitation is the underlying cause of the first part of #51499.

To rectify this, the commit implements the following:
1. generalizes aggressive inference to apply to all child frames, when
they are not cached.
2. enables aggressive constant propagation, allowing the propagation of
mutable Consts.

With these changes, now we can get:
```julia
julia> getkeyelem(d). # TAB completes

julia> getkeyelem(d).value.

compile_options
match_options
pattern
regex
```

In conjunction with #51502, this resolves #51499.
@brenhinkeller brenhinkeller added the REPL Julia's REPL (Read Eval Print Loop) label Oct 3, 2023
Pangoraw added a commit to Pangoraw/FuzzyCompletions.jl that referenced this pull request Oct 7, 2023
aviatesk pushed a commit to JunoLab/FuzzyCompletions.jl that referenced this pull request Oct 25, 2023
* Backport several changes from `REPL.REPLCompletions`

 - JuliaLang/julia#51502
 - JuliaLang/julia#51345

* make field_completion_eligible true for 1.6

Base._which was added in
JuliaLang/julia@7b19e09

* Update FuzzyCompletions.jl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants