Clojure

keyword function returns nil on bad input

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test

Description

The keyword function should throw an exception on bad input rather than return nil.

user=> (keyword 5)
nil
user=> (keyword [])
nil

Cause: The keyword function is defined as a cond with cases for keywords, symbols, and strings. There is no :else so all other cases return nil.

Proposal: Add an :else branch and throw an exception in keyword.

Patch:

Activity

Eric Normand made changes -
Field Original Value New Value
Attachment keyword-1341-2014-02-12.patch [ 12786 ]
Eric Normand made changes -
Attachment keyword-1341-2014-02-12.2.patch [ 12787 ]
Andy Fingerhut made changes -
Patch Code and Test [ 10002 ]

People

Vote (0)
Watch (3)

Dates

  • Created:
    Updated: