Clojure

Empty PersistentCollections get incorrectly evaluated as their generic clojure counterpart

Details

  • Type: Defect Defect
  • Status: Reopened Reopened
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.4, Release 1.5
  • Fix Version/s: Release 1.7
  • Component/s: None
  • Patch:
    Code and Test
  • Approval:
    Incomplete

Description

user> (defrecord x [])
user.x
user> #user.x[]   ;; expect: #user.x{}
{}
user> #user.x{}   ;; expect: #user.x{}
{}
user> #clojure.lang.PersistentTreeMap[]
{}
user> (class *1)  ;; expect: clojure.lang.PersistentTreeMap
clojure.lang.PersistentArrayMap

Cause: Compiler's ConstantExpr parser returns an EmptyExpr for all empty persistent collections, even if they are of types other than the core collections (for example: records, sorted collections, custom collections). EmptyExpr reports its java class as one the classes - IPersistentList/IPersistentVector/IPersistentMap/IPersistentSet rather than the original type.

Proposed: If one of the Persistent* classes, then create EmptyExpr as before, otherwise retain the ConstantExpression of the original collection.
Since EmptyExpr is a compiler optimization that applies only to some concrete clojure collections, making EmptyExpr dispatch on concrete types rather than on generic interfaces makes the compiler behave as expected

Patch: 0001-CLJ-1093-fix-compilation-of-empty-PersistentCollecti.patch

Screened by:

Activity

Nicola Mometto made changes -
Field Original Value New Value
Attachment 001-fix-empty-record-literal.patch [ 11609 ]
Timothy Baldridge made changes -
Assignee Timothy Baldridge [ halgari ]
Timothy Baldridge made changes -
Approval Not Approved [ 10008 ]
Timothy Baldridge made changes -
Resolution Declined [ 2 ]
Status Open [ 1 ] Resolved [ 5 ]
Stuart Halloway made changes -
Status Resolved [ 5 ] Closed [ 6 ]
Nicola Mometto made changes -
Approval Not Approved [ 10008 ]
Status Closed [ 6 ] Reopened [ 4 ]
Resolution Declined [ 2 ]
Andy Fingerhut made changes -
Nicola Mometto made changes -
Attachment 001-fix-empty-record-literal.patch [ 11609 ]
Nicola Mometto made changes -
Attachment 0001-CLJ-1093-fix-empty-records-literal-v2.patch [ 12047 ]
Nicola Mometto made changes -
Description before patch:
user=> (defrecord a [b])
user.a
user=> #user.a{}
{}

after patch:
user=> (defrecord a [b])
user.a
user=> #user.a{}
#user.a{:b nil}
before patch:
user=> (defrecord a [b])
user.a
user=> #user.a{}
{}
user=> (class #clojure.lang.PersistentTreeMap[])
clojure.lang.PersistentArrayMap

after patch:
user=> (defrecord a [b])
user.a
user=> #user.a{}
#user.a{:b nil}
user=> (class #clojure.lang.PersistentTreeMap[])
clojure.lang.PersistentTreeMap

Attachment 0001-CLJ-1093-fix-empty-records-literal-v2.patch [ 12048 ]
Summary Empty record literals gets incorrectly evaluated to array-maps Empty PersistentCollections get incorrectly evaluated as their generic clojure counterpart
Nicola Mometto made changes -
Attachment 0001-CLJ-1093-fix-empty-records-literal-v2.patch [ 12047 ]
Alex Miller made changes -
Approval Triaged [ 10120 ]
Rich Hickey made changes -
Approval Triaged [ 10120 ] Vetted [ 10003 ]
Alex Miller made changes -
Description before patch:
user=> (defrecord a [b])
user.a
user=> #user.a{}
{}
user=> (class #clojure.lang.PersistentTreeMap[])
clojure.lang.PersistentArrayMap

after patch:
user=> (defrecord a [b])
user.a
user=> #user.a{}
#user.a{:b nil}
user=> (class #clojure.lang.PersistentTreeMap[])
clojure.lang.PersistentTreeMap

{code}
user> (defrecord x [])
user.x
user> #user.x[]
{}
user> #user.x{}
{}
{code}
Priority Major [ 3 ] Minor [ 4 ]
Alex Miller made changes -
Description {code}
user> (defrecord x [])
user.x
user> #user.x[]
{}
user> #user.x{}
{}
{code}
{code}
user> (defrecord x [])
user.x
user> #user.x[]
{}
user> #user.x{}
{}
user> #clojure.lang.PersistentTreeMap[]
{}
user> (class *1)
clojure.lang.PersistentArrayMap
{code}

*Cause:*

*Proposed:*

*Patch:*

*Screened by:*
Alex Miller made changes -
Description {code}
user> (defrecord x [])
user.x
user> #user.x[]
{}
user> #user.x{}
{}
user> #clojure.lang.PersistentTreeMap[]
{}
user> (class *1)
clojure.lang.PersistentArrayMap
{code}

*Cause:*

*Proposed:*

*Patch:*

*Screened by:*
{code}
user> (defrecord x [])
user.x
user> #user.x[]
{}
user> #user.x{}
{}
user> #clojure.lang.PersistentTreeMap[]
{}
user> (class *1)
clojure.lang.PersistentArrayMap
{code}

*Cause:* Compiler's ConstantExpr parser returns an EmptyExpr for all empty persistent collections, even if they are of types other than the core collections (for example: records, sorted collections, custom collections). EmptyExpr reports its java class as one the classes - IPersistentList/IPersistentVector/IPersistentMap/IPersistentSet rather than the original type.

*Proposed:* If one of the Persistent* classes, then create EmptyExpr as before, otherwise retain the ConstantExpression of the original collection.

*Patch:* 0001-CLJ-1093-fix-empty-records-literal-v2.patch

*Screened by:*
Rich Hickey made changes -
Fix Version/s Release 1.7 [ 10250 ]
Alex Miller made changes -
Approval Vetted [ 10003 ] Incomplete [ 10006 ]
Assignee Timothy Baldridge [ halgari ]
Alex Miller made changes -
Labels collections compiler
Nicola Mometto made changes -
Attachment 0001-CLJ-1093-fix-empty-collection-literal-evaluation.patch [ 13015 ]
Alex Miller made changes -
Approval Incomplete [ 10006 ] Vetted [ 10003 ]
Alex Miller made changes -
Description {code}
user> (defrecord x [])
user.x
user> #user.x[]
{}
user> #user.x{}
{}
user> #clojure.lang.PersistentTreeMap[]
{}
user> (class *1)
clojure.lang.PersistentArrayMap
{code}

*Cause:* Compiler's ConstantExpr parser returns an EmptyExpr for all empty persistent collections, even if they are of types other than the core collections (for example: records, sorted collections, custom collections). EmptyExpr reports its java class as one the classes - IPersistentList/IPersistentVector/IPersistentMap/IPersistentSet rather than the original type.

*Proposed:* If one of the Persistent* classes, then create EmptyExpr as before, otherwise retain the ConstantExpression of the original collection.

*Patch:* 0001-CLJ-1093-fix-empty-records-literal-v2.patch

*Screened by:*
{code}
user> (defrecord x [])
user.x
user> #user.x[]
{}
user> #user.x{}
{}
user> #clojure.lang.PersistentTreeMap[]
{}
user> (class *1)
clojure.lang.PersistentArrayMap
{code}

*Cause:* Compiler's ConstantExpr parser returns an EmptyExpr for all empty persistent collections, even if they are of types other than the core collections (for example: records, sorted collections, custom collections). EmptyExpr reports its java class as one the classes - IPersistentList/IPersistentVector/IPersistentMap/IPersistentSet rather than the original type.

*Proposed:* If one of the Persistent* classes, then create EmptyExpr as before, otherwise retain the ConstantExpression of the original collection.

*Patch:* 0001-CLJ-1093-fix-empty-collection-literal-evaluation.patch

*Screened by:*
Nicola Mometto made changes -
Attachment 0001-CLJ-1093-fix-empty-collection-literal-evaluation.patch [ 13027 ]
Nicola Mometto made changes -
Attachment 0001-CLJ-1093-fix-empty-collection-literal-evaluation.patch [ 13015 ]
Alex Miller made changes -
Description {code}
user> (defrecord x [])
user.x
user> #user.x[]
{}
user> #user.x{}
{}
user> #clojure.lang.PersistentTreeMap[]
{}
user> (class *1)
clojure.lang.PersistentArrayMap
{code}

*Cause:* Compiler's ConstantExpr parser returns an EmptyExpr for all empty persistent collections, even if they are of types other than the core collections (for example: records, sorted collections, custom collections). EmptyExpr reports its java class as one the classes - IPersistentList/IPersistentVector/IPersistentMap/IPersistentSet rather than the original type.

*Proposed:* If one of the Persistent* classes, then create EmptyExpr as before, otherwise retain the ConstantExpression of the original collection.

*Patch:* 0001-CLJ-1093-fix-empty-collection-literal-evaluation.patch

*Screened by:*
{code}
user> (defrecord x [])
user.x
user> #user.x[] ;; expect: #user.x{}
{}
user> #user.x{} ;; expect: #user.x{}
{}
user> #clojure.lang.PersistentTreeMap[]
{}
user> (class *1) ;; expect: clojure.lang.PersistentTreeMap
clojure.lang.PersistentArrayMap
{code}

*Cause:* Compiler's ConstantExpr parser returns an EmptyExpr for all empty persistent collections, even if they are of types other than the core collections (for example: records, sorted collections, custom collections). EmptyExpr reports its java class as one the classes - IPersistentList/IPersistentVector/IPersistentMap/IPersistentSet rather than the original type.

*Proposed:* If one of the Persistent* classes, then create EmptyExpr as before, otherwise retain the ConstantExpression of the original collection.

*Patch:* 0001-CLJ-1093-fix-empty-collection-literal-evaluation.patch

*Screened by:*
Alex Miller made changes -
Approval Vetted [ 10003 ] Incomplete [ 10006 ]
Nicola Mometto made changes -
Attachment 0001-CLJ-1093-fix-empty-records-literal-v2.patch [ 12048 ]
Nicola Mometto made changes -
Attachment 0001-CLJ-1093-fix-empty-collection-literal-evaluation.patch [ 13027 ]
Nicola Mometto made changes -
Nicola Mometto made changes -
Description {code}
user> (defrecord x [])
user.x
user> #user.x[] ;; expect: #user.x{}
{}
user> #user.x{} ;; expect: #user.x{}
{}
user> #clojure.lang.PersistentTreeMap[]
{}
user> (class *1) ;; expect: clojure.lang.PersistentTreeMap
clojure.lang.PersistentArrayMap
{code}

*Cause:* Compiler's ConstantExpr parser returns an EmptyExpr for all empty persistent collections, even if they are of types other than the core collections (for example: records, sorted collections, custom collections). EmptyExpr reports its java class as one the classes - IPersistentList/IPersistentVector/IPersistentMap/IPersistentSet rather than the original type.

*Proposed:* If one of the Persistent* classes, then create EmptyExpr as before, otherwise retain the ConstantExpression of the original collection.

*Patch:* 0001-CLJ-1093-fix-empty-collection-literal-evaluation.patch

*Screened by:*
{code}
user> (defrecord x [])
user.x
user> #user.x[] ;; expect: #user.x{}
{}
user> #user.x{} ;; expect: #user.x{}
{}
user> #clojure.lang.PersistentTreeMap[]
{}
user> (class *1) ;; expect: clojure.lang.PersistentTreeMap
clojure.lang.PersistentArrayMap
{code}

*Cause:* Compiler's ConstantExpr parser returns an EmptyExpr for all empty persistent collections, even if they are of types other than the core collections (for example: records, sorted collections, custom collections). EmptyExpr reports its java class as one the classes - IPersistentList/IPersistentVector/IPersistentMap/IPersistentSet rather than the original type.

*Proposed:* If one of the Persistent* classes, then create EmptyExpr as before, otherwise retain the ConstantExpression of the original collection.
Since EmptyExpr is a compiler optimization that applies only to some concrete clojure collections, making EmptyExpr dispatch on concrete types rather than on generic interfaces makes the compiler behave as expected

*Patch:* 0001-CLJ-1093-fix-empty-collection-literal-evaluation.patch

*Screened by:*
Nicola Mometto made changes -
Description {code}
user> (defrecord x [])
user.x
user> #user.x[] ;; expect: #user.x{}
{}
user> #user.x{} ;; expect: #user.x{}
{}
user> #clojure.lang.PersistentTreeMap[]
{}
user> (class *1) ;; expect: clojure.lang.PersistentTreeMap
clojure.lang.PersistentArrayMap
{code}

*Cause:* Compiler's ConstantExpr parser returns an EmptyExpr for all empty persistent collections, even if they are of types other than the core collections (for example: records, sorted collections, custom collections). EmptyExpr reports its java class as one the classes - IPersistentList/IPersistentVector/IPersistentMap/IPersistentSet rather than the original type.

*Proposed:* If one of the Persistent* classes, then create EmptyExpr as before, otherwise retain the ConstantExpression of the original collection.
Since EmptyExpr is a compiler optimization that applies only to some concrete clojure collections, making EmptyExpr dispatch on concrete types rather than on generic interfaces makes the compiler behave as expected

*Patch:* 0001-CLJ-1093-fix-empty-collection-literal-evaluation.patch

*Screened by:*
{code}
user> (defrecord x [])
user.x
user> #user.x[] ;; expect: #user.x{}
{}
user> #user.x{} ;; expect: #user.x{}
{}
user> #clojure.lang.PersistentTreeMap[]
{}
user> (class *1) ;; expect: clojure.lang.PersistentTreeMap
clojure.lang.PersistentArrayMap
{code}

*Cause:* Compiler's ConstantExpr parser returns an EmptyExpr for all empty persistent collections, even if they are of types other than the core collections (for example: records, sorted collections, custom collections). EmptyExpr reports its java class as one the classes - IPersistentList/IPersistentVector/IPersistentMap/IPersistentSet rather than the original type.

*Proposed:* If one of the Persistent* classes, then create EmptyExpr as before, otherwise retain the ConstantExpression of the original collection.
Since EmptyExpr is a compiler optimization that applies only to some concrete clojure collections, making EmptyExpr dispatch on concrete types rather than on generic interfaces makes the compiler behave as expected

*Patch:* 0001-CLJ-1093-fix-compilation-of-empty-PersistentCollecti.patch

*Screened by:*

People

Vote (4)
Watch (4)

Dates

  • Created:
    Updated: