<< Back to previous view

[CLJ-1107] 'get' should throw exception on non-Associative argument Created: 13/Nov/12  Updated: 13/Nov/12

Status: Open
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Stuart Sierra Assignee: Stuart Sierra
Resolution: Unresolved Votes: 1
Labels: None

Attachments: Text File 0001-CLJ-1107-Throw-exception-for-get-called-on-unsupport.patch    
Patch: Code and Test

 Description   

The implementation of clojure.core/get returns null if its argument is not a valid associative collection. However, calling 'get' on something which is neither nil nor an Associative collection is almost certainly a bug, and should be indicated by an exception.

This behavior can obscure common programmer errors such as:

(def a (atom {:a 1 :b 2})

(:foo a)   ; forgot to deref a
;;=> nil

CLJ-932 was accepted as a similar enhancement to 'clojure.core/contains?'

Attached patch 0001 throws an IllegalArgumentException as the fall-through case of RT.getFrom.


Generated at Sun May 19 23:44:08 CDT 2013 using JIRA 4.4#649-r158309.