ClojureScript

Keyword self-lookups to return default value when appropriate

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Originally reported by Evan Mezeske in a comment on CLJS-330.

Due to a missing -invoke arity in cljs.core.Keyword's implementation of IFn, calls like (:foo {} 1) fail to produce the given default value.

Activity

Hide
Michał Marczyk added a comment -

Note the case with not-found doesn't bother to check if it's dealing with an ObjMap. This is because an ObjMap is capable of holding nil or false as a value, so we would still need to call contains? which on an ObjMap does exactly the same work as -lookup, except it returns true / false thus forcing us to pick the correct return value.

Show
Michał Marczyk added a comment - Note the case with not-found doesn't bother to check if it's dealing with an ObjMap. This is because an ObjMap is capable of holding nil or false as a value, so we would still need to call contains? which on an ObjMap does exactly the same work as -lookup, except it returns true / false thus forcing us to pick the correct return value.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: