Clojure

Clojure loses quoted metadata on empty literals

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: Release 1.5, Release 1.6
  • Fix Version/s: Release 1.7
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Vetted

Description

meta on empty collections is lost:

user=> (meta '^:foo [])
nil   ;; expected {:foo true} as in:
user=> (meta '^:foo [1])
{:foo true}

This bug propagates to ^:const vars:

user=> (def ^:const foo ^:foo [])
#'user/foo
user=> (meta foo)
nil
user=> (meta @#'foo)
{:foo true}

Cause: As in CLJ-1093, empty collections are replaced with an EmptyExpr that loses meta

Proposed: Don't replace with EmptyExpr if meta is present.

Patch: 001-CLJ-1187.patch (NOTE: this change overlaps with CLJ-1093 and the patch there may be preferred)

Screened by:

Activity

Nicola Mometto made changes -
Field Original Value New Value
Attachment 001-CLJ-1187.patch [ 11926 ]
Nicola Mometto made changes -
Patch Code and Test [ 10002 ]
Stuart Halloway made changes -
Approval Triaged [ 10120 ]
Nicola Mometto made changes -
Attachment 001-CLJ-1187.patch [ 11926 ]
Nicola Mometto made changes -
Attachment 001-CLJ-1187.patch [ 11931 ]
Nicola Mometto made changes -
Summary Quoted empty literals lose metadata Clojure loses quoted metdata on empty literals
Nicola Mometto made changes -
Attachment 001-CLJ-1187.patch [ 11931 ]
Nicola Mometto made changes -
Attachment 001-CLJ-1187.patch [ 11943 ]
Rich Hickey made changes -
Approval Triaged [ 10120 ] Vetted [ 10003 ]
Rich Hickey made changes -
Fix Version/s Release 1.6 [ 10157 ]
Gabriel Horner made changes -
Assignee Gabriel Horner [ cldwalker ]
Gabriel Horner made changes -
Approval Vetted [ 10003 ] Screened [ 10004 ]
Assignee Gabriel Horner [ cldwalker ]
Summary Clojure loses quoted metdata on empty literals Clojure loses quoted metadata on empty literals
Nicola Mometto made changes -
Description user=> (meta '^:foo [])
nil

while
user=> (meta '^:foo [1])
{:foo true}

This bug propagates to ^:const vars:
user=> (def ^:const foo ^:foo [])
#'user/foo
user=> (meta foo)
nil
user=> (meta @#'foo)
{:foo true}
##NOTE##
CLJ-1093 contains a patch that fixes this issue aswell and should be preferred



user=> (meta '^:foo [])
nil

while
user=> (meta '^:foo [1])
{:foo true}

This bug propagates to ^:const vars:
user=> (def ^:const foo ^:foo [])
#'user/foo
user=> (meta foo)
nil
user=> (meta @#'foo)
{:foo true}
Alex Miller made changes -
Approval Screened [ 10004 ] Vetted [ 10003 ]
Alex Miller made changes -
Approval Vetted [ 10003 ] Incomplete [ 10006 ]
Alex Miller made changes -
Fix Version/s Release 1.6 [ 10157 ]
Alex Miller made changes -
Approval Incomplete [ 10006 ] Vetted [ 10003 ]
Alex Miller made changes -
Description ##NOTE##
CLJ-1093 contains a patch that fixes this issue aswell and should be preferred



user=> (meta '^:foo [])
nil

while
user=> (meta '^:foo [1])
{:foo true}

This bug propagates to ^:const vars:
user=> (def ^:const foo ^:foo [])
#'user/foo
user=> (meta foo)
nil
user=> (meta @#'foo)
{:foo true}
meta on empty collections is lost:

{code}
user=> (meta '^:foo [])
nil ;; expected {:foo true} as in:
user=> (meta '^:foo [1])
{:foo true}
{code}

This bug propagates to ^:const vars:
{code}
user=> (def ^:const foo ^:foo [])
#'user/foo
user=> (meta foo)
nil
user=> (meta @#'foo)
{:foo true}
{code}

*Cause:* As in CLJ-1093, empty collections are replaced with an EmptyExpr that loses meta

*Proposed:* Don't replace with EmptyExpr if meta is present.

*Patch:* 001-CLJ-1187.patch (NOTE: this change overlaps with CLJ-1093 and the patch there may be preferred)

*Screened by:*
Rich Hickey made changes -
Fix Version/s Release 1.7 [ 10250 ]
Alex Miller made changes -
Resolution Duplicate [ 3 ]
Status Open [ 1 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: