Index: generic/nsf.c =================================================================== diff -u -r764ac30a3ca9712d9fc59853b36759e1dd146114 -r4b9ddd1b06ce34fd352791fcae53ad91a79b43ce --- generic/nsf.c (.../nsf.c) (revision 764ac30a3ca9712d9fc59853b36759e1dd146114) +++ generic/nsf.c (.../nsf.c) (revision 4b9ddd1b06ce34fd352791fcae53ad91a79b43ce) @@ -9403,14 +9403,9 @@ cscPtr->flags, (cscPtr->flags & NSF_CSC_CALL_IS_NRE), pcPtr, result);*/ #if defined(NSF_WITH_ASSERTIONS) - if (unlikely(opt && object->teardown && (opt->checkoptions & CHECK_POST))) { - int rc; - /* - * Even, when the returned result != TCL_OK, run assertion to report - * the highest possible method from the call-stack (e.g. "set" would not - * be very meaningful; however, do not flush a TCL_ERROR. - */ - rc = AssertionCheck(interp, object, cscPtr->cl, data[2], CHECK_POST); + if (unlikely(opt && object->teardown && (opt->checkoptions & CHECK_POST)) + && likely(result == TCL_OK)) { + int rc = AssertionCheck(interp, object, cscPtr->cl, data[2], CHECK_POST); if (rc != TCL_OK) { result = rc; } @@ -9694,7 +9689,7 @@ } #if defined(NSF_WITH_ASSERTIONS) - if (unlikely(object->opt != NULL)) { + if (unlikely(object->opt != NULL) && likely(result == TCL_OK)) { CheckOptions co = object->opt->checkoptions; if ((co & CHECK_INVAR)) { int rc = AssertionCheckInvars(interp, object, Tcl_GetCommandName(interp, cmd), co); Index: library/xotcl/tests/testx.xotcl =================================================================== diff -u -r35c0d6ecb3c83cc6d6b0dfe251ba1a0d9071dc30 -r4b9ddd1b06ce34fd352791fcae53ad91a79b43ce --- library/xotcl/tests/testx.xotcl (.../testx.xotcl) (revision 35c0d6ecb3c83cc6d6b0dfe251ba1a0d9071dc30) +++ library/xotcl/tests/testx.xotcl (.../testx.xotcl) (revision 4b9ddd1b06ce34fd352791fcae53ad91a79b43ce) @@ -261,7 +261,7 @@ a set x 1 a check all } - ::errorCheck $err {assertion failed check: {$x == 1} in proc 'xTo2'} \ + ::errorCheck $err {assertion failed check: {$x == 1} in proc 'set'} \ "inheritance a xTo2" if {![catch {a yTo2} err]} { @@ -280,7 +280,7 @@ b set x 1 b check all } - ::errorCheck $err {assertion failed check: {$x == 1} in proc 'xTo2'} \ + ::errorCheck $err {assertion failed check: {$x == 1} in proc 'set'} \ "inheritance b xTo2" if {![catch {b yTo2} err]} { Index: tests/methods.test =================================================================== diff -u -r764ac30a3ca9712d9fc59853b36759e1dd146114 -r4b9ddd1b06ce34fd352791fcae53ad91a79b43ce --- tests/methods.test (.../methods.test) (revision 764ac30a3ca9712d9fc59853b36759e1dd146114) +++ tests/methods.test (.../methods.test) (revision 4b9ddd1b06ce34fd352791fcae53ad91a79b43ce) @@ -1090,17 +1090,29 @@ :public method foo {} { :configure -xxx 1 } + :public method bar {} { + :configure -xxx 1 + } -postcondition {{1 == 0}} :create e1 } # base case ? {catch {e1 foo} errMsg} 1 ? {string match "invalid non-positional*" $errMsg} 1 + ? {catch {e1 bar} errMsg} 1 + ? {string match "invalid non-positional*" $errMsg} 1 + + # turn on assertion checking nsf::method::assertion e1 check all - # still report error + # still report error when invariant would not return error ? {catch {e1 foo} errMsg} 1 ? {string match "invalid non-positional*" $errMsg} 1 + + # still report error when postcondition would not return error + ? {catch {e1 bar} errMsg} 1 + ? {string match "invalid non-positional*" $errMsg} 1 + }