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

0 votes
in Compiler by

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.

8 Answers

0 votes
by

Comment made by: desk@danielcompton.net

Is there a compiler change required as well here?

0 votes
by

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.

0 votes
by

Comment made by: michaelblume

Yes, that.

0 votes
by

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.

0 votes
by

Comment made by: alexmiller

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).

0 votes
by

Comment made by: jafingerhut

(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.

0 votes
by

Comment made by: alexmiller

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
`

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