Clojure

Misleading ClassCastException when coercing a String to int

Details

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

Description

Observed behaviour

(int "0") =>
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character

Expected behaviour
(int "0") =>
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
or
IllegalArgumentException

Activity

Hide
Andy Fingerhut added a comment -

If someone wants to improve the behavior of int in this case, they should also consider similar improvements to the error messages for unchecked-int, char, and unchecked-char.

Show
Andy Fingerhut added a comment - If someone wants to improve the behavior of int in this case, they should also consider similar improvements to the error messages for unchecked-int, char, and unchecked-char.
Hide
Michael Drogalis added a comment - - edited

Patch improved-int-char-casting-error-messages.diff on January 6, 2013.

Show
Michael Drogalis added a comment - - edited Patch improved-int-char-casting-error-messages.diff on January 6, 2013.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: