Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message for mismatching sorts in substitutions #6093

Merged
merged 1 commit into from
Jun 13, 2022

Conversation

rindPHI
Copy link
Contributor

@rindPHI rindPHI commented Jun 13, 2022

When substituting expressions in the Z3 API, the error message in case of a sort mismatch was confusing:

import z3

# x * y
expr = z3.Int('x') * z3.Int('y')

# (x * y)[z / x]
subst_expr = z3.substitute(expr, (z3.Int('x'), z3.Int('z')))

# Wrong type:
try:
    subst_expr = z3.substitute(expr, (z3.String('x'), z3.Int('z')))
except z3.z3types.Z3Exception as exc:
    print(exc)  # -> "Z3 invalid substitution, expression pairs expected."

In the above example, expression pairs were passed, only with the wrong type. This issue confused me a lot in my beginner times with Z3, and currently, it's confusing my students ;)

This pull request leads to the, in my opinion more meaningful, error message 'Z3 invalid substitution, mismatching "from" and "to" sorts.' in that case.

@NikolajBjorner NikolajBjorner merged commit 46bc726 into Z3Prover:master Jun 13, 2022
@NikolajBjorner
Copy link
Contributor

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants