We're updating the issue view to help you get more done. 

calling hashCode on clojure.lang.LazyTransformer causes a StackOverflowError

Description

Calling .hashCode on a an instance of clojure.lang.LazyTransformer causes a StackOverflowError:

1 2 user> (.hashCode (sequence (map identity) ["s"])) StackOverflowError clojure.lang.Util.hash (Util.java:161)

The trace is

1 2 3 4 5 6 7 8 Util.java: 161 clojure.lang.Util/hash LazyTransformer.java: 216 clojure.lang.LazyTransformer/hashCode Util.java: 161 clojure.lang.Util/hash LazyTransformer.java: 216 clojure.lang.LazyTransformer/hashCode Util.java: 161 clojure.lang.Util/hash LazyTransformer.java: 216 clojure.lang.LazyTransformer/hashCode Util.java: 161 clojure.lang.Util/hash LazyTransformer.java: 216 clojure.lang.LazyTransformer/hashCode

Relevant lines:

1 2 https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LazyTransformer.java#L212 https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Util.java#L161

Cause: Looks like "seq" returns "this":

https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LazyTransformer.java#L55

This does NOT occur on an empty sequence, as clojure.core/sequence short-circuits.

Proposal: compute and cache hash and hasheq using same algorithm used in other seqs

Patch: CLJ-1600-2.patch

Screened by: Alex Miller

Environment

OS X 10.10.1, Macbook Pro,, Java 1.8.0_11, Clojure 1.7.0-alpha4

Status

Assignee

Unassigned

Reporter

import

Labels

Approval

Ok

Patch

Code and Test

Fix versions

Affects versions

Release 1.7

Priority

Major