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

Handle infix operators in REPL completion #51366

Merged
merged 3 commits into from
Oct 12, 2023

Conversation

Liozou
Copy link
Member

@Liozou Liozou commented Sep 18, 2023

Fix #51194

This PR fixes a regression introduced in #49294, so I believe it should be backported to v1.10.
In the current code, completion of qux(foo, bar. is detected by parsing foo(qux, bar as an incomplete expression, and then looking for the sub-expression to complete (here, bar.). This approach fails however for infix calls, since completing foo + bar. starts by parsing foo + bar, which is a complete call expression, and so the code behaves as if completing (foo + bar). instead of bar.. This leads to the current problematic behaviour:

julia> Complex(1, 3) + (4//5).#TAB
im
re

which would be correct for (Complex(1, 3) + (4//5)).#TAB, but here we expect

julia> Complex(1, 3) + (4//5).#TAB
den
num

This PR fixes that by trying to detect infix calls. In the long term, all this ad-hoc and probably somewhat wrong string processing should be replaced by proper use of JuliaSyntax (as mentioned in #49294 (comment), #50817 (comment) and probably other places), but for now at least this fixes the regression.

@Liozou Liozou added REPL Julia's REPL (Read Eval Print Loop) backport 1.10 Change should be backported to the 1.10 release labels Sep 18, 2023
@KristofferC KristofferC merged commit e949236 into JuliaLang:master Oct 12, 2023
6 checks passed
KristofferC pushed a commit that referenced this pull request Oct 12, 2023
Fix #51194

This PR fixes a regression introduced in
#49294, so I believe it should be
backported to v1.10.
In the current code, completion of `qux(foo, bar.` is detected by
parsing `foo(qux, bar` as an incomplete expression, and then looking for
the sub-expression to complete (here, `bar.`). This approach fails
however for infix calls, since completing `foo + bar.` starts by parsing
`foo + bar`, which is a complete call expression, and so the code
behaves as if completing `(foo + bar).` instead of `bar.`. This leads to
the current problematic behaviour:
```julia
julia> Complex(1, 3) + (4//5).#TAB
im
re
```
which would be correct for `(Complex(1, 3) + (4//5)).#TAB`, but here we
expect
```julia
julia> Complex(1, 3) + (4//5).#TAB
den
num
```

This PR fixes that by trying to detect infix calls. In the long term,
all this ad-hoc and probably somewhat wrong string processing should be
replaced by proper use of `JuliaSyntax` (as mentioned in
#49294 (comment),
#50817 (comment)
and probably other places), but for now at least this fixes the
regression.

(cherry picked from commit e949236)
@Liozou Liozou deleted the replcompleteinfix branch October 18, 2023 15:07
KristofferC added a commit that referenced this pull request Nov 2, 2023
Backported PRs:
- [x] #50932 <!-- types: fix hash values of Vararg -->
- [x] #50975 <!-- Use rr-safe `nopl; rdtsc` sequence -->
- [x] #50989 <!-- fix incorrect results in `expm1(::Union{Float16,
Float32})` -->
- [x] #51284 <!-- Avoid infinite loop when doing SIGTRAP in arm64-apple
-->
- [x] #51332 <!-- Add s4 field to Xoshiro -->
- [x] #51397 <!-- call Pkg precompile hook in latest world -->
- [x] #51405 <!-- Remove fallback that assigns a module to inlined
frames. -->
- [x] #51491 <!-- Throw clearer ArgumentError for strip with two string
args -->
- [x] #51531 <!-- fix `_tryonce_download_from_cache` (busybox.exe
download error) -->
- [x] #51541 <!-- Fix string index error in tab completion code -->
- [x] #51530 <!-- Don't mark nonlocal symbols as hidden -->
- [x] #51557 <!-- Fix last startup & shutdown precompiles -->
- [x] #51512 <!-- avoid limiting Type{Any} to Type -->
- [x] #51595 <!-- reset `maxprobe` on `empty!` -->
- [x] #51582 <!-- Aggressive constprop in LinearAlgebra.wrap -->
- [x] #51592 <!-- correctly track element pointer in heap snapshot -->
- [x] #51326 <!-- complete false & true more generally as vals -->
- [x] #51376 <!-- make `hash(::Xoshiro)` compatible with `==` -->
- [x] #51557 <!-- Fix last startup & shutdown precompiles -->
- [x] #51845 
- [x] #51840 
- [x] #50663 <!-- Fix Expr(:loopinfo) codegen -->
- [x] #51863 <!-- LLVM 15.0.7-9 -->

Contains multiple commits, manual intervention needed:

- [ ] #51035 <!-- refactor GC scanning code to reflect jl_binding_t are
now first class -->
- [ ] #51092 <!-- inference: fix bad effects for recursion -->

Non-merged PRs with backport label:
- [ ] #51479 <!-- prevent code loading from lookin in the versioned
environment when building Julia -->
- [ ] #51414 <!-- improvements on GC scheduler shutdown -->
- [ ] #51366 <!-- Handle infix operators in REPL completion -->
- [ ] #50919 <!-- Code loading: do the "skipping mtime check for stdlib"
check regardless of the value of `ispath(f)` -->
- [ ] #50824 <!-- Add some aliasing warnings to docstrings for mutating
functions in Base -->
- [ ] #49805 <!-- Limit TimeType subtraction to AbstractDateTime -->
@KristofferC KristofferC removed the backport 1.10 Change should be backported to the 1.10 release label Nov 6, 2023
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.

Tab expansion of NamedTuple fails on 1.10.0-beta2
3 participants