diff --git a/docs/src/manual/nonlinear.md b/docs/src/manual/nonlinear.md index 28f644fb9e9..2b001d21f70 100644 --- a/docs/src/manual/nonlinear.md +++ b/docs/src/manual/nonlinear.md @@ -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. [...] ``` diff --git a/src/variables.jl b/src/variables.jl index e41dab40a28..e5f6103393b 100644 --- a/src/variables.jl +++ b/src/variables.jl @@ -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) diff --git a/test/test_variable.jl b/test/test_variable.jl index 66f73f7f5ef..319a4717727 100644 --- a/test/test_variable.jl +++ b/test/test_variable.jl @@ -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