-
Notifications
You must be signed in to change notification settings - Fork 40
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
data reader depends on imports being available? #55
Comments
I do not know why this happens, but off the top of my head as a guess, perhaps adding an import or three into the code, and/or replacing some occurrence of IPersistentVector with clojure.lang.IPersistentVector in the code of the ordered library, might avoid this behavior? |
@kolharsam Is this something you'd be interested in helping to fix? |
@borkdude I'll try and get back to you soon. Upon investigating it further. If you've got any ideas, please share :) |
In an experiment with Clojure 1.10.1 and this ordered library, I made a local change to the
With only those changes, the REPL sequence in the original issue gives no exceptions or messages of any kind. I do not know all the rules here, but I will point out that this Clojure source code written by Rich Hickey uses fully qualified interface/class names in similar situations: https://github.com/clojure/clojure/blob/master/src/clj/clojure/gvec.clj |
I would guess there should be no harm in replacing all occurrences of such Java class/interface names with their fully qualified counterparts, throughout this library, other than a few extra characters in the source code. |
@jafingerhut I found one occurrence here: ordered/src/flatland/ordered/map.clj Line 29 in 714f32a
I guess the solution that you suggested is already present. Would it be wrong to think that something else might be the cause of the error? |
@kolharsam The lines of code you reference that are in the current latest version of this library:
lead to the exception being thrown in the REPL when attempting to evaluate the sequence of expressions in the first comment of this issue. My experiment was to change those lines to something similar, but not the same as they currently are. Look carefully for the changes. I guarantee you my suggested replacement lines are different than the current ones:
|
@jafingerhut What you suggested seems to be working for the sequence above. And also my apologies for not looking at it carefully initially. Should I write some test(s) for this? Also, might there be other classes where this problem might occur? You did already suggest replacing all of the classnames with their fully qualified names. Should I be doing that as well? Or would that better in a different fix/issue altogether? |
It might be best to only change the occurrences that cause the symptoms of this problem to go away, which seem to be the ones in my previous message for the ordered maps. For ordered sets, I bet there is a similar issue, and a similar fix. It would be good if there were a way to write a test that fails for the current code, but succeeds with the fix. I do not understand why this test is passing, for example, given the behavior at a REPL given in the original issue: https://github.com/clj-commons/ordered/blob/master/test/flatland/ordered/map_test.clj#L184-L187 |
Given this interaction below, I do not know how to add a failing test for the current code, since
|
It is not due to Leiningen or nrepl, as I guessed in my previous comment, because I get the same behavior with the Clojure CLI It is due to attempting to |
@jafingerhut I have added these 2 commits, would it be sufficient to resolve this issue? (to submit a PR) Also, I'm interested in how/when did you realize that |
Why the formatting change in kolharsam@fa854a0? And how do you test if the issue was resolved? |
@kolharsam asked: "I'm interested in how/when did you realize that eval was causing the problem?" Two clues: (1) The first is the stack trace in my previous comment, that came as output from evaluating (2) The call to |
Also, as borkdude mentioned, it would be good to add a test that fails without the fix, and passes with the fix. The tests that you reformat in one of your commits are interesting. They include |
I think I see now. The second commit you point at is a reformatting one only, after another separate commit just before that which added those tests. Those tests do not exist in the latest master of the original repository, so that is why the latest master is not failing those tests. You should also add similar tests for ordered sets as the one you added for ordered maps. |
Ah right. Just to confirm, did the tests you added fail without the fix @kolharsam? |
@borkdude affirmative! |
@jafingerhut upon adding similar tests for |
@kolharsam I think so, yes. |
this is was the solution discussed at clj-commons#55
these tests fail if the changes in the parent commit are not present. thereby helping to resolve clj-commons#55
Consider the following REPL sequence:
It seems the data reader only works when certain imports are in place?
The text was updated successfully, but these errors were encountered: