probcomp / Venturecxx

Primary implementation of the Venture probabilistic programming system
http://probcomp.csail.mit.edu/venture/
GNU General Public License v3.0
28 stars 6 forks source link

assert errors do not show context #652

Open marcoct opened 8 years ago

marcoct commented 8 years ago

In some cases, some context is annotated, however it is non-specific (see second example).

venture[script] > assert(False, "this is a message")
*** evaluation: this is a message
(autorun (assert false "this is a message"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Caused by
this is a message
venture[script] > infer { x_val <- sample(normal(0, 1)); assert(x_val < -100, "error message") }
*** evaluation: error message
(run (do (x_val <- (sample (normal 0 1))) (assert (lt x_val (sub 0 100)) "error message")))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Caused by
error message

If the assert takes place within an in_model context, it appears there is no annotation at all:

venture[script] > infer { m <- new_model(); in_model(m, { x_val <- sample(normal(0, 1)); assert(x_val < -100, "x_val is not less than -100") }) }
*** evaluation: x_val is not less than -100
Caused by
x_val is not less than -100

If assert statements do not provide messages for some reason, then the error is literally "Caused by:", and all we know is that the program crashed.

marcoct commented 8 years ago

Also, the Caused by message could be improved to include the word 'assertion error' or something to that effect.