Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/manual/nonlinear.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ julia> f(x::Vector{VariableRef}) = x[1] > 1 ? 0 : x[2]
f (generic function with 1 method)

julia> f(x)
ERROR: Cannot evaluate `>` between a variable and a number.
ERROR: Cannot evaluate `<` between a variable and a number.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only downside. We might talk about < when the user wrote >.

[...]
```

Expand Down
2 changes: 1 addition & 1 deletion src/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3403,7 +3403,7 @@ There are three common mistakes that lead to this.
)
end

for sym in (:(<=), :(>=), :(<), :(>))
for sym in (:(<=), :(<))
err = _logic_error_exception(sym)
@eval begin
Base.$(sym)(::GenericVariableRef, ::Number) = throw($err)
Expand Down
8 changes: 4 additions & 4 deletions test/test_variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1107,12 +1107,12 @@ end
function test_error_messages()
model = Model()
@variable(model, x)
@test_throws JuMP._logic_error_exception(:>=) x >= 1
@test_throws JuMP._logic_error_exception(:>=) 1 >= x
@test_throws JuMP._logic_error_exception(:<=) x >= 1
@test_throws JuMP._logic_error_exception(:<=) 1 >= x
@test_throws JuMP._logic_error_exception(:<=) x <= 1
@test_throws JuMP._logic_error_exception(:<=) 1 <= x
@test_throws JuMP._logic_error_exception(:>) x > 1
@test_throws JuMP._logic_error_exception(:>) 1 > x
@test_throws JuMP._logic_error_exception(:<) x > 1
@test_throws JuMP._logic_error_exception(:<) 1 > x
@test_throws JuMP._logic_error_exception(:<) x < 1
@test_throws JuMP._logic_error_exception(:<) 1 < x
return
Expand Down
Loading