[CLJ-1107] 'get' should throw exception on non-Associative argument Created: 13/Nov/12 Updated: 14/Feb/14
|Reporter:||Stuart Sierra||Assignee:||Stuart Sierra|
|Attachments:||0001-CLJ-1107-Throw-exception-for-get-called-on-unsupport.patch 0003-CLJ-1107-Throw-exception-for-get-on-unsupported-type.patch clj-1107-throw-on-get-for-unsupported-types-patch-v2.txt|
|Patch:||Code and Test|
The implementation of clojure.core/get returns nil if its argument is not an associative collection.
This behavior can obscure common programmer errors such as:
Calling get on something which is neither nil nor an Associative collection is almost certainly a bug, and should be indicated by an exception.
Approach: Throw IllegalArgumentException as final fall-through case in RT.getFrom instead of returning nil.
|Comment by Andy Fingerhut [ 24/May/13 12:31 PM ]|
Patch clj-1107-throw-on-get-for-unsupported-types-patch-v2.txt dated May 24 2013 is identical to 0001-CLJ-1107-Throw-exception-for-get-called-on-unsupport.patch dated Nov 13 2012, except it applies cleanly to latest master. A recent commit for
|Comment by Andy Fingerhut [ 30/Jan/14 5:01 PM ]|
Patch clj-1107-throw-on-get-for-unsupported-types-patch-v2.txt applied cleanly to latest Clojure master as of Jan 23 2014, but no longer does with commits made to Clojure between then and Jan 30 2014. I have not checked to see how difficult or easy it may be to update this patch.
|Comment by Stuart Sierra [ 11/Feb/14 7:23 AM ]|
New patch 0003-CLJ-1107-Throw-exception-for-get-on-unsupported-type.patch created from master at 5cc167a.