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

Improve error message when confusing = with == in @constraint? #3891

Closed
jd-foster opened this issue Nov 25, 2024 · 0 comments · Fixed by #3892
Closed

Improve error message when confusing = with == in @constraint? #3891

jd-foster opened this issue Nov 25, 2024 · 0 comments · Fixed by #3892

Comments

@jd-foster
Copy link
Collaborator

Users may fairly easily confuse = with == in @constraint

cf. https://discourse.julialang.org/t/problem-setting-constraint-in-simple-lp-using-jump/123059

Minimal example

julia> function simple_confusion()
           model = Model()
           @variable(model, x)
           @variable(model, y)
           @constraint(model, x + y = 0)
end
ERROR: LoadError: MethodError: Cannot `convert` an object of type Expr to an object of type Symbol
The function `convert` exists, but no method is defined for this combination of argument types.

Is there a way to throw a more informative error that helps users debug this (likely common) mistake?

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

Successfully merging a pull request may close this issue.

1 participant