BlueBrain / nmodl

Code Generation Framework For NEURON MODeling Language
https://bluebrain.github.io/nmodl/
Apache License 2.0
48 stars 15 forks source link

Make SympyVisitor fail on error. #1259

Open 1uc opened 1 month ago

1uc commented 1 month ago

Currently, when the SympyVisitor detects a bug, it simply prints a warning and continues. The tests also assert that the SympyVisitor is idempotent:

        THEN("More SympySolver passes do nothing to the AST and don't throw") {
            REQUIRE_NOTHROW(run_sympy_visitor_passes(*ast));
            REQUIRE(AST_string == ast_to_string(*ast));
        }

Unfortunately, the output of SymPy is not valid input to SymPy. This is why when it fails it the assumption is that the visitor already ran. Then it kindly warns, just in case the assumption is wrong and carries on.

Therefore, simple fixes such as: https://github.com/BlueBrain/nmodl/pull/1257

fail.

This leads to confusing error messages: https://github.com/BlueBrain/nmodl/issues/1258

1uc commented 1 month ago

@pramodk Do we need the property that the visitor can be reapplied, even though its output is invalid input?