Shinmera / parachute

An extensible and cross-compatible testing framework.
https://shinmera.github.io/parachute
zlib License
97 stars 9 forks source link

capture-error should use the value of the form, to ensure the compiler does not optimize it away #22

Closed Yehouda closed 3 years ago

Yehouda commented 3 years ago

capture-error does (and ,form nil), which means that the value of form is not used, and therefore the compiler can optimize it if it is pure (not destructive). For example, (and (aref <something> <index>) nil) can be optimized to (progn <something><index> nil), because the call to aref cannot validly do anything except returning a value that is not used.

Actually cause an issue in the 3d-matrices tests https://github.com/Shinmera/3d-matrices/blob/master/test.lisp, where it wants to see an error from (fail (mcref (matn 1 2) 1 0)), but mcref inlines to aref which is optimized away as above.

Shinmera commented 3 years ago

Thanks!