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

def-map-type broken in 0.3.12-SNAPSHOT #34

Closed
luxbock opened this issue Dec 23, 2014 · 7 comments
Closed

def-map-type broken in 0.3.12-SNAPSHOT #34

luxbock opened this issue Dec 23, 2014 · 7 comments

Comments

@luxbock
Copy link

luxbock commented Dec 23, 2014

Trying to evaluate this:

(def-map-type MyMap [x]
  (get [_ key default] (get x key default))
  (assoc [_ key val] (assoc x key val))
  (dissoc [_ key] (dissoc x key))
  (keys [_] (keys x)))

Results in this:

1. Caused by java.lang.IllegalArgumentException
   No single method: with_meta_STAR_ of interface:
   potemkin.collections.PotemkinMap found for function: with-meta* of protocol:
   PotemkinMap

                 Compiler.java: 3566  clojure.lang.Compiler$InvokeExpr/<init>
                 Compiler.java: 3773  clojure.lang.Compiler$InvokeExpr/parse
                 Compiler.java: 6711  clojure.lang.Compiler/analyzeSeq
                 Compiler.java: 6500  clojure.lang.Compiler/analyze
                 Compiler.java: 6461  clojure.lang.Compiler/analyze
                 Compiler.java: 5837  clojure.lang.Compiler$BodyExpr$Parser/parse
                 Compiler.java: 8073  clojure.lang.Compiler$NewInstanceMethod/parse
                 Compiler.java: 7609  clojure.lang.Compiler$NewInstanceExpr/build
                 Compiler.java: 7490  clojure.lang.Compiler$NewInstanceExpr$DeftypeParser/parse
                 Compiler.java: 6709  clojure.lang.Compiler/analyzeSeq
                 Compiler.java: 6500  clojure.lang.Compiler/analyze
                 Compiler.java: 6461  clojure.lang.Compiler/analyze
                 Compiler.java: 5837  clojure.lang.Compiler$BodyExpr$Parser/parse
                 Compiler.java: 6155  clojure.lang.Compiler$LetExpr$Parser/parse
                 Compiler.java: 6709  clojure.lang.Compiler/analyzeSeq
                 Compiler.java: 6500  clojure.lang.Compiler/analyze
                 Compiler.java: 6461  clojure.lang.Compiler/analyze
                 Compiler.java: 5837  clojure.lang.Compiler$BodyExpr$Parser/parse
                 Compiler.java: 5272  clojure.lang.Compiler$FnMethod/parse
                 Compiler.java: 3901  clojure.lang.Compiler$FnExpr/parse
                 Compiler.java: 6707  clojure.lang.Compiler/analyzeSeq
                 Compiler.java: 6500  clojure.lang.Compiler/analyze
                 Compiler.java: 6765  clojure.lang.Compiler/eval
                 Compiler.java: 6757  clojure.lang.Compiler/eval
                 Compiler.java: 7195  clojure.lang.Compiler/load
                          REPL:    1  user/eval14701
                 Compiler.java: 6768  clojure.lang.Compiler/eval
                 Compiler.java: 6731  clojure.lang.Compiler/eval
                      core.clj: 3076  clojure.core/eval
                      main.clj:  239  clojure.main/repl/read-eval-print/fn
                      main.clj:  239  clojure.main/repl/read-eval-print
                      main.clj:  257  clojure.main/repl/fn
                      main.clj:  257  clojure.main/repl
                   RestFn.java: 1523  clojure.lang.RestFn/invoke
        interruptible_eval.clj:   67  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                      AFn.java:  152  clojure.lang.AFn/applyToHelper
                      AFn.java:  144  clojure.lang.AFn/applyTo
                      core.clj:  626  clojure.core/apply
                      core.clj: 1864  clojure.core/with-bindings*
                   RestFn.java:  425  clojure.lang.RestFn/invoke
        interruptible_eval.clj:   51  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
        interruptible_eval.clj:  183  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
        interruptible_eval.clj:  152  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                      AFn.java:   22  clojure.lang.AFn/run
       ThreadPoolExecutor.java: 1145  java.util.concurrent.ThreadPoolExecutor/runWorker
       ThreadPoolExecutor.java:  615  java.util.concurrent.ThreadPoolExecutor$Worker/run
                   Thread.java:  744  java.lang.Thread/run

@ztellman
Copy link
Collaborator

Maps now require meta and with-meta handlers. The example should be updated.

@ztellman
Copy link
Collaborator

I've updated the related documentation.

@luxbock
Copy link
Author

luxbock commented Dec 23, 2014

Is the branch for 0.3.12-SNAPSHOT private? I would like to see the updated example.

I feel like I've gone through every possible combination of with-meta, withMeta, meta on their own and with clojure.lang.IObj but I keep running into the same exception every time.

@ztellman
Copy link
Collaborator

Sorry, I made the change just before going to bed, and apparently neglected to actually submit it. Let me know if the example in the docs doesn't work for you.

@luxbock
Copy link
Author

luxbock commented Dec 25, 2014

I'm trying this:

(def-map-type Foo [x]
  (get [this key default] (get x key default))
  (assoc [this key val] (assoc x key val))
  (dissoc [this key] (dissoc x key))
  (keys [this] (keys x))
  (meta [this] (meta x))
  (with-meta [this m] (Foo. (with-meta x m))))

which fails with:

CompilerException java.lang.IllegalArgumentException: No single method: with_meta_STAR_ of interface: potemkin.collections.PotemkinMap found for function: with-meta* of protocol: PotemkinMap, compiling:(/Users/Olli/Development/clojure/herm/src/herm/game/ranges.clj:76:5) 

I feel like I might be overlooking something really simple, but shouldn't this be working?

EDIT:
The README example fails with the same exception.

@ztellman
Copy link
Collaborator

Your code works for me on the latest code in master (and I believe should have been working for a while). Are you sure that's what you're using?

@luxbock
Copy link
Author

luxbock commented Dec 25, 2014

You are right. There was a conflict with my profiles.clj file, with the following dependency vector: [leiningen #=(leiningen.core.main/leiningen-version)]. I had it in there because vinyasa requires it. I don't know what about it is that causes the problem, but I have got rid of it now. Thanks for your patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants