Clojure

Test that collections are valid statements

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test

Description

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.

  1. clj-1776-v1.patch
    08/Jul/15 1:14 PM
    1 kB
    Michael Blume
  2. CLJ-1776-v2.patch
    03/Feb/17 4:56 PM
    1 kB
    Michael Blume

Activity

Hide
Daniel Compton added a comment -

Is there a compiler change required as well here?

Show
Daniel Compton added a comment - Is there a compiler change required as well here?
Hide
Alex Miller added a comment -

I think he is saying that the compiler is fine but that if it weren't, no test would tell you that.

Show
Alex Miller added a comment - I think he is saying that the compiler is fine but that if it weren't, no test would tell you that.
Hide
Michael Blume added a comment -

Yes, that.

Show
Michael Blume added a comment - Yes, that.
Hide
Andy Fingerhut added a comment -

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.

Show
Andy Fingerhut added a comment - 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.
Hide
Alex Miller added a comment -

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

Show
Alex Miller added a comment - 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).
Hide
Andy Fingerhut added a comment -

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

Show
Andy Fingerhut added a comment - [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.
Hide
Alex Miller added a comment -

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
Show
Alex Miller added a comment - 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

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: