Skip to content

Update clojure.core-test.take-nth to use doall - #919

Merged
jeaye merged 2 commits into
jank-lang:mainfrom
djblue:fix-take-nth
Jun 27, 2026
Merged

Update clojure.core-test.take-nth to use doall#919
jeaye merged 2 commits into
jank-lang:mainfrom
djblue:fix-take-nth

Conversation

@djblue

@djblue djblue commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

So the exception that is being caused by this test is indirectly testing that a Clojure dialect supports IDrop:

Since jank doesn't implement such an optimization, this test was failing because getting the first element doesn't result in calling pos?. However getting any element after would cause the same exception in jank. You get the exact same behavior in clojure if the collection does not implement IDrop:

% clj
Clojure 1.12.2
user=> (do (seq (take-nth nil (range 10))) :foo) ;; clojure.lang.LongRange implements IDrop
Execution error (NullPointerException) at user/eval1 (REPL:1).
Cannot invoke "Object.getClass()" because "x" is null
user=> (do (seq (take-nth nil (list 0 1))) :foo) ;; clojure.lang.PersistentList does not
:foo
user=> 

I think using doall allows us to ignore this minor implementation detail.

Comment thread test/clojure/core_test/take_nth.cljc
@djblue
djblue requested a review from jeaye June 27, 2026 19:05
@jeaye
jeaye merged commit ee781a7 into jank-lang:main Jun 27, 2026
5 checks passed
@jeaye

jeaye commented Jun 27, 2026

Copy link
Copy Markdown
Member

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants