Clojure

(.containsKey {:one 1} :one) throws Exception

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: Release 1.3, Release 1.4, Release 1.5
  • Fix Version/s: Release 1.5, Release 1.6
  • Component/s: None
  • Labels:
    None
  • Environment:
    Clojure 1.3 om Mac OS 10.7, Clojure 1.5.0 alpha1 on Linux x86_64 (OpenJDK 1.7.0 b147)
  • Patch:
    Code
  • Approval:
    Vetted

Description

Patch clj944-plus-tests does three things:

  • includes the previous "0002" patch which has the compiler emit map types consistent with the reader
  • adds tests
  • removes tests that were broken all along and now symptomatic

Hi guys, I am getting the following exception:

(.containsKey {:one 1} :one)
;=> ClassCastException clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.PersistentHashMap

The map is a clojure.lang.PersistentArrayMap, which obviously has a containsKey method (https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentArrayMap.java#L95).

Casting it works fine though:

(.containsKey ^clojure.lang.PersistentArrayMap {:one 1} :one)
;=> true

The mailing list suggest that the compiler injects an incorrect cast to clojure.lang.PersistentHashMap. In this case it should probably be cast to a clojure.lang.Associative, the highest common interface having the .containsKey method.

The problem is not present in Clojure 1.2.1.

  1. 0001-Fix-for-CLJ-944.patch
    30/Oct/12 5:02 PM
    0.9 kB
    Nicola Mometto
  2. 0002-Fix-for-CLJ-944.patch
    01/Nov/12 3:48 PM
    1 kB
    Nicola Mometto
  3. clj944-plus-tests.patch
    12/Apr/13 3:57 PM
    5 kB
    Stuart Halloway

Activity

Michel Alexandre Salim made changes -
Field Original Value New Value
Environment Clojure 1.3 om Mac OS 10.7 Clojure 1.3 om Mac OS 10.7, Clojure 1.5.0 alpha1 on Linux x86_64 (OpenJDK 1.7.0 b147)
Affects Version/s Release 1.5 [ 10150 ]
Affects Version/s Release 1.4 [ 10040 ]
Affects Version/s Release 1.3 [ 10038 ]
Nicola Mometto made changes -
Attachment 0001-Fix-for-CLJ-944.patch [ 11644 ]
Nicola Mometto made changes -
Attachment 0002-Fix-for-CLJ-944.patch [ 11655 ]
Andy Fingerhut made changes -
Patch Code [ 10001 ]
Stuart Halloway made changes -
Approval Triaged [ 10120 ]
Rich Hickey made changes -
Approval Triaged [ 10120 ] Vetted [ 10003 ]
Priority Minor [ 4 ] Major [ 3 ]
Rich Hickey made changes -
Fix Version/s Release 1.6 [ 10157 ]
Fix Version/s Release 1.5 [ 10150 ]
Stuart Halloway made changes -
Approval Vetted [ 10003 ] Screened [ 10004 ]
Description Hi guys, I am getting the following exception:

{code}
(.containsKey {:one 1} :one)
;=> ClassCastException clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.PersistentHashMap
{code}

The map is a clojure.lang.PersistentArrayMap, which obviously has a containsKey method (https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentArrayMap.java#L95).

Casting it works fine though:

{code}
(.containsKey ^clojure.lang.PersistentArrayMap {:one 1} :one)
;=> true
{code}

The mailing list suggest that the compiler injects an incorrect cast to clojure.lang.PersistentHashMap. In this case it should probably be cast to a clojure.lang.Associative, the highest common interface having the .containsKey method.

The problem is not present in Clojure 1.2.1.
Patch clj944-plus-tests does three things:

* includes the previous "0002" patch which has the compiler emit map types consistent with the reader
* adds tests
* removes tests that were broken all along and now symptomatic

Hi guys, I am getting the following exception:

{code}
(.containsKey {:one 1} :one)
;=> ClassCastException clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.PersistentHashMap
{code}

The map is a clojure.lang.PersistentArrayMap, which obviously has a containsKey method (https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentArrayMap.java#L95).

Casting it works fine though:

{code}
(.containsKey ^clojure.lang.PersistentArrayMap {:one 1} :one)
;=> true
{code}

The mailing list suggest that the compiler injects an incorrect cast to clojure.lang.PersistentHashMap. In this case it should probably be cast to a clojure.lang.Associative, the highest common interface having the .containsKey method.

The problem is not present in Clojure 1.2.1.
Attachment clj944-plus-tests.patch [ 11955 ]
Rich Hickey made changes -
Approval Screened [ 10004 ] Vetted [ 10003 ]

People

Vote (2)
Watch (3)

Dates

  • Created:
    Updated: