Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

According to the docstring for doseq, the following should return nil.

user> (doseq [] "not nil") "not nil"

6 Answers

0 votes
by

Comment made by: admay

I think this fixes this issue.

Theres a (do ...) that runs if (seq exprs) is nil but the return of that do isn't necessarily nil if your body is something that doesn't return nil.

0 votes
by

Comment made by: mfikes

It is odd that {{doseq}} even has code for this case given that the docstring indicates the bindings and filterings are as provided by "for." Since {{for}} requires one or more binding forms, it raises the question of whether {{(doseq [] "not nil")}} is a valid program.

0 votes
by

Comment made by: alexmiller

Test?

0 votes
by

Comment made by: admay

Here's a bit of tests! I think these are suitable for the use case of doseq. I just went with similar tests to dotimes since they're so similar.

0 votes
by

Comment made by: admay

I removed the println from the original tests in favor of identity. It seemed more appropriate so you don't have a random 'foo' in the test print-out.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-2283 (reported by ambrosebs)
...