The compiler ignores too few or too many arguments to throw

Description

The compiler does not fail on "malformed" throw forms with less than or greater than one arg:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 user=> (defn foo [] (throw)) #'user/foo user=> (foo) NullPointerException user/foo (NO_SOURCE_FILE:1) user=> (defn bar [] (throw Exception baz)) #'user/bar user=> (bar) ClassCastException java.lang.Class cannot be cast to java.lang.Throwable user/bar (NO_SOURCE_FILE:1) ; This one works, but ignored-symbol, should probably not be ignored user=> (defn quux [] (throw (Exception. "Works!") ignored-symbol)) #'user/quux user=> (quux) Exception Works! user/quux (NO_SOURCE_FILE:1)

Approach: Count forms and throw an appropriate exception if arity != 1.

Patch: clj-1456-5.patch

Screened by: Alex Miller

Environment

None

Status

Assignee

Unassigned

Reporter

Alf Kristian Støyle

Labels

Approval

Ok

Patch

Code and Test

Fix versions

Affects versions

Release 1.6

Priority

Major
Configure