Change in exception seen during eval of macro with precondition

Description

Difference in test behavior seen in Clojure 1.10 vs 1.9:

Then:

Note that there are several unique factors about this case, specifically that it involves a macro precondition, triggered in an eval, in a deftest "is".

Just throwing an exception (no precondition involved) shows no change in behavior:

Full exception trace when it fails on 1.10:

Environment

None

Activity

Alex Miller 
December 27, 2018 at 3:32 PM

Declining per comments above, but may consider mods related to the clojure test assertions.

Alex Miller 
December 21, 2018 at 6:37 PM

The exception being thrown here is happening during macroexpansion under eval and, unavoidably, code like this is exposed to some of internal machinery. In this case, we don't make any commitments to how exceptions thrown during macroexpansion flows exceptions up through the compiler.

Some alternatives to checking this kind of case:

  • have macros call functions for validation, and test those functions independently from the macros

  • use thrown?, but don't rely on a particular exception type

  • define your own assert-expr variant that checks the root cause exception rather than the one caught

Alex Miller 
December 19, 2018 at 1:16 AM

Having looked at a little more, it's not clear to me how to avoid seeing the wrapper in this nestsed macroexpansion case. I think we could probably tweak thrown? and thrown-with-msg? to ignore a CompilerException wrapper and/or to use the root cause. I'm not sure if that's just making different problems though.

Declined

Details

Assignee

Reporter

Approval

Priority

Affects versions

Created December 19, 2018 at 12:55 AM
Updated December 27, 2018 at 3:32 PM
Resolved December 27, 2018 at 3:32 PM