Skip to content

Commit 8c6da2d

Browse files
committed
CLJCLR-189: Make clojure.core.Num throw an Exception on non-numeric types. (Better match to JVM behavior.)
1 parent ec5c324 commit 8c6da2d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Clojure/Clojure/Lib/Numbers.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,8 +2123,11 @@ static public object abs(object x)
21232123
#region converters to object
21242124

21252125

2126-
public static object num(object x) { return x; }
2127-
2126+
public static object num(object x) {
2127+
if (!Util.IsNumeric(x))
2128+
throw new InvalidCastException("Argument is not numeric");
2129+
return x;
2130+
}
21282131

21292132
public static object num(float x) { return x; }
21302133

0 commit comments

Comments
 (0)