Empty PersistentCollections get incorrectly evaluated as their generic clojure counterpart

Description

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-v2.patch

Screened by:

Environment

None

Attachments

3

Activity

Show:

Alex Miller August 5, 2015 at 9:45 PM

Nicola Mometto July 30, 2015 at 10:08 PM

Yes, this ticket is about empty IPCs, and the only way a record can be empty is if it has 0 fields

Andy Fingerhut July 30, 2015 at 10:04 PM

Is it true that the only record ctors affected by this are those that have 0 fields? At least cursory testing with similar examples as in the description, but with 1 field in the record, show what seems to be the expected behavior.

Nicola Mometto July 30, 2015 at 9:13 PM

Really? The fact that record ctor syntax doesn't roundtrip is not a bug?

Stuart Halloway July 30, 2015 at 8:55 PM

More subtle than, but not a bug for the same reasons as, CLJ-1460.

Completed

Details

Assignee

Reporter

Patch

Code and Test

Priority

Affects versions

Fix versions

Created October 24, 2012 at 3:13 PM
Updated August 7, 2015 at 3:13 PM
Resolved August 7, 2015 at 3:13 PM