Welcome! Please see the About page for a little more info on how this works.
It's possible to break the compiler such that vectors are emitted incorrectly when they're in statement position (I accidentally did this). This doesn't break any part of the Clojure test suite, but does break valid Clojure code (for me it hit taoensso's encore). Add tests to the test suite so defects of this kind are caught.
Comment made by: desk@danielcompton.net
Is there a compiler change required as well here?
Comment made by: alexmiller
I think he is saying that the compiler is fine but that if it weren't, no test would tell you that.
Comment made by: michaelblume
Yes, that.
Comment made by: jafingerhut
Is it an accident that the Clojure compiler accepts 'code' like this? If I saw Clojure code like this in a project, I think I would assume it was an error.
Seems like it should be valid code to me (although there is not much reason to ever do this unless it's the last expression in a body).
(link: facepalm) Yes, of course this should be valid in return position, for returning such a vector or map. Away from return position is the odd-looking thing, but as you say, no reason the compiler should reject it.
Note that the elements of a collection will be evaluated, so side effects triggered by code in the collection will be executed.
` user=> (let []
`
[(future (println "hi")) (future (println "there"))] 1)
hi there 1 `