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-derived-map has a broken hashCode if any key is nil #52

Closed
csm opened this Issue Jun 20, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@csm

csm commented Jun 20, 2017

(require '[potemkin :as p])
(p/def-derived-map Up [v] :value (some-> v (.toUpperCase)))
(.hashCode (->Up nil))

Expected a hash code returned, got a NullPointerException.

E.g. in a repl:

#error{:cause nil,
       :via [{:type java.lang.NullPointerException,
              :message nil,
              :at [user.Up$fn__17016 invoke "form-init4972760988041368194.clj" 121]}],
       :trace [[user.Up$fn__17016 invoke "form-init4972760988041368194.clj" 121]
               [clojure.core.protocols$fn__6755 invokeStatic "protocols.clj" 167]
               [clojure.core.protocols$fn__6755 invoke "protocols.clj" 124]
               [clojure.core.protocols$fn__6710$G__6705__6719 invoke "protocols.clj" 19]
               [clojure.core.protocols$seq_reduce invokeStatic "protocols.clj" 31]
               [clojure.core.protocols$fn__6736 invokeStatic "protocols.clj" 75]
               [clojure.core.protocols$fn__6736 invoke "protocols.clj" 75]
               [clojure.core.protocols$fn__6684$G__6679__6697 invoke "protocols.clj" 13]
               [clojure.core$reduce invokeStatic "core.clj" 6545]
               [clojure.core$reduce invoke "core.clj" 6527]
               [user.Up hashCode "form-init4972760988041368194.clj" 119]
               [sun.reflect.NativeMethodAccessorImpl invoke0 "NativeMethodAccessorImpl.java" -2]
               [sun.reflect.NativeMethodAccessorImpl invoke "NativeMethodAccessorImpl.java" 62]
               [sun.reflect.DelegatingMethodAccessorImpl invoke "DelegatingMethodAccessorImpl.java" 43]
               [java.lang.reflect.Method invoke "Method.java" 498]
               [clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 93]
               [clojure.lang.Reflector invokeNoArgInstanceMember "Reflector.java" 313]
               [user$eval17059 invokeStatic "form-init4972760988041368194.clj" 1]
               [user$eval17059 invoke "form-init4972760988041368194.clj" 1]
               [clojure.lang.Compiler eval "Compiler.java" 6927]
               [clojure.lang.Compiler eval "Compiler.java" 6890]
               [clojure.core$eval invokeStatic "core.clj" 3105]
               [clojure.core$eval invoke "core.clj" 3101]
               [clojure.main$repl$read_eval_print__7408$fn__7411 invoke "main.clj" 240]
               [clojure.main$repl$read_eval_print__7408 invoke "main.clj" 240]
               [clojure.main$repl$fn__7417 invoke "main.clj" 258]
               [clojure.main$repl invokeStatic "main.clj" 258]
               [clojure.main$repl doInvoke "main.clj" 174]
               [clojure.lang.RestFn invoke "RestFn.java" 1523]
               [clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__952 invoke "interruptible_eval.clj" 87]
               [clojure.lang.AFn applyToHelper "AFn.java" 152]
               [clojure.lang.AFn applyTo "AFn.java" 144]
               [clojure.core$apply invokeStatic "core.clj" 646]
               [clojure.core$with_bindings_STAR_ invokeStatic "core.clj" 1881]
               [clojure.core$with_bindings_STAR_ doInvoke "core.clj" 1881]
               [clojure.lang.RestFn invoke "RestFn.java" 425]
               [clojure.tools.nrepl.middleware.interruptible_eval$evaluate invokeStatic "interruptible_eval.clj" 85]
               [clojure.tools.nrepl.middleware.interruptible_eval$evaluate invoke "interruptible_eval.clj" 55]
               [clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__997$fn__1000
                invoke
                "interruptible_eval.clj"
                222]
               [clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__992 invoke "interruptible_eval.clj" 190]
               [clojure.lang.AFn run "AFn.java" 22]
               [java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1142]
               [java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 617]
               [java.lang.Thread run "Thread.java" 745]]}
@dpsutton

This comment has been minimized.

Show comment
Hide comment
@dpsutton

dpsutton Jun 21, 2017

Contributor

patch here #53

Contributor

dpsutton commented Jun 21, 2017

patch here #53

@dpsutton

This comment has been minimized.

Show comment
Hide comment
@dpsutton

dpsutton Jun 22, 2017

Contributor

this can be closed due to #53

Contributor

dpsutton commented Jun 22, 2017

this can be closed due to #53

@csm

This comment has been minimized.

Show comment
Hide comment
@csm

csm commented Jun 22, 2017

👍

@csm csm closed this Jun 22, 2017

emidln added a commit to curiosity/potemkin that referenced this issue Jun 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment