lazy recursive definition giving incorrect results

Description

If you define a global data var in terms of a lazy sequence referring to that same var, you can get different results depending on the chunkiness of laziness of the functions being used to build the collection.

Clojure's lazy sequences don't promise to support this, but they shouldn't return wrong answers. In the example given in http://groups.google.com/group/clojure/browse_thread/thread/1c342fad8461602d (and repeated below), Clojure should not return bad data. An error message would be good, and even an infinite loop would be more reasonable than the current behavior.

(Similar issue reported here: https://groups.google.com/d/topic/clojure/yD941fIxhyE/discussion)

Environment

None

Attachments

2

Activity

Show:

Nicola Mometto August 3, 2015 at 4:01 PM

Alex, the posted example is no longer reproducible because `(range)` does not produce a chunked-seq anymore.
OTOH `(range n)` does so replacing `(range)` with something like `(range Long/MAX_VALUE)` in the code example in the ticket description is sufficient to resurface the bug:

Alex Miller August 3, 2015 at 1:46 AM

No longer reproducible

Andy Fingerhut November 23, 2013 at 6:35 AM

Patch clj-457-3.diff is identical to Christophe's CLJ-457-2.diff, except it has been updated to no longer conflict with the commit made for CLJ-949 on Nov 22, 2013, which basically removed the try/catch in method sval(). It passes tests, and I don't see anything wrong with it, but it would be good if Christophe could give it a look, too.

Christophe Grand December 3, 2012 at 5:18 PM

New patch with a comment explaining the expected states.
Note: I tidied the states table up.

is also fixed by this patch.

Andy Fingerhut November 30, 2012 at 8:06 PM

That last comment, Christophe, goes a long way to explaining the idea to me, at least. Any chance comments with similar content could be added as part of the patch?

Details

Assignee

Reporter

Patch

Code and Test

Priority

Created October 13, 2010 at 9:00 PM
Updated August 3, 2015 at 4:21 PM