-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Faulty logic in info op #86
Comments
Sounds like we should have some additional check for qualified symbols. I don't remember the code details that much myself, but this should be easy to enough to fix. I guess there might also be an assumption that the caller should take care of the check, but it won't hurt to make the code in Perhaps @jeffvalk will have something to add on this topic as well. |
I can have a look at this, probably a simple addition to the conditional logic there, thank you for the detailed report! |
…huffle clj-meta A treaty could be written on the intricacies of clj-meta. Previously, java/resolve-symbol was not correctly consulted when resolving qualified symbols. Moreover it was returning both static member information AND type information. The bug detected that this is not sufficient, cause we need to We treat it now as a special case and we move it to the top. Unit tests were also added for both issues in the ticket.
A treaty could be written on the intricacies of clj-meta. Previously, java/resolve-symbol was at the end of the chain and was not consulted, cause conflicts in unqualified names, like max, would result in earlier returns (for instance of clojure.core/max). The problem is deeper and moving java/resolve-symbol up would not solve all the problems, as it is doing two things: returning static member information AND type information. Basically it broke records and macro refer resolution. This patch splits that function in two: java/resolve-symbol only checks if there exist Java members, and java/resolve-type only takes care of full classes and records. Interleaving the two with (m/resolve-var unqualified-sym) magically fulfills all the use cases. There be dragons.
The case with Integer/max was solved, thanks! However the issue still remains with the other case where the symbol can't be resolved, like |
Probably we'll have to do a deeper clean-up of that codebase at some point, as there's a lot of mess there. I might get to doing this in a month or so, but I can make no promises, as my backlog is already quite full. Any help is welcome! |
I would dare to disagree the code is a mess 😅 It's more Clojure's semantics non-linear - in any case of course any help is appreciated if I don't get to it soon. I am quite confused though by the non-existent use case cause we test it and the test passed. I will try to get there again |
I think this one should be reopened. This is the problem we have and it is one I am not sure how to solve. The tension is between these two payloads (the first was part of #53):
The problem is that there exists both a This is all good, except that it means I resolve |
I think I will have to special-case for
|
Nope, the problem is not with refer actually, it's about the symbol ambiguity. I will have to think about something else |
@arichiardi We can do what we do with Java methods and return multiple candidates that the user can manually select, while defaulting the to the Clojure sym for |
@bbatsov Doesn't |
@yuhan0 I reallly really tried but I don't think I can produce a In order to make pragmatic choices, I wonder if you can show me the piece of code (in cider) that presents the defect...I want to see if it is acceptable to display something like Thanks! |
This patch unfixes clojure-emacs#86. It basically tries to restore a more linear flow in clj-info and orchard.java, distinguishing a bit more between qualified and unqualified patterns.
The main entry point is The other route is I wouldn't say it's unacceptable to display |
Here's a contrived example: (ns foo)
(defn get [x] "not clojure.core!") (ns bar
(:require [foo])
;; via cider-uneval or some REPL command:
(ns-unmap 'foo 'get)
(foo/get :something) ;; <- cursor here, displays eldoc for clojure.core/get |
Solved by #134 , thanks! |
Indeed! That PR comes to implement |
Thank you! |
Expected behavior
When calling
orchard.info/info
on a Java member or non-existent fully qualified symbol, the unqualified symbol should not be used to resolve a var in the current namespace.should return the info for the
Integer.max
Java static member andnil
respectively.Actual behavior
Instead the unqualified symbols
max
andget
are resolved to the clojure.core functions and produces an incorrect info response.I traced it to this line in clj-meta:
orchard/src/orchard/info.clj
Line 76 in ccf90fe
Even though
sym
is fully qualified, the processing stepnormalise-params
added the key:unqualified-sym
. I don't know enough to say if it's a predecence issue or if there should be an additional condition to not resolve unqualified-sym if the sym is fully qualified.Steps to reproduce the problem
In Emacs, call
cider-doc
on the symbolInteger/max
or observe the eldoc which displays the wrong arglists forclojure.core/max
.Environment & Version information
Clojure version
E.g. 1.10.2
Java version
E.g. 1.11
Operating system
macOS 10.15
The text was updated successfully, but these errors were encountered: