Skip to content

Commit 21a9c01

Browse files
authored
Don’t add methods to the functions > and >= (#4065)
1 parent 4056c00 commit 21a9c01

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

docs/src/manual/nonlinear.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ julia> f(x::Vector{VariableRef}) = x[1] > 1 ? 0 : x[2]
476476
f (generic function with 1 method)
477477
478478
julia> f(x)
479-
ERROR: Cannot evaluate `>` between a variable and a number.
479+
ERROR: Cannot evaluate `<` between a variable and a number.
480480
[...]
481481
```
482482

src/variables.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3403,7 +3403,7 @@ There are three common mistakes that lead to this.
34033403
)
34043404
end
34053405

3406-
for sym in (:(<=), :(>=), :(<), :(>))
3406+
for sym in (:(<=), :(<))
34073407
err = _logic_error_exception(sym)
34083408
@eval begin
34093409
Base.$(sym)(::GenericVariableRef, ::Number) = throw($err)

test/test_variable.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,12 +1107,12 @@ end
11071107
function test_error_messages()
11081108
model = Model()
11091109
@variable(model, x)
1110-
@test_throws JuMP._logic_error_exception(:>=) x >= 1
1111-
@test_throws JuMP._logic_error_exception(:>=) 1 >= x
1110+
@test_throws JuMP._logic_error_exception(:<=) x >= 1
1111+
@test_throws JuMP._logic_error_exception(:<=) 1 >= x
11121112
@test_throws JuMP._logic_error_exception(:<=) x <= 1
11131113
@test_throws JuMP._logic_error_exception(:<=) 1 <= x
1114-
@test_throws JuMP._logic_error_exception(:>) x > 1
1115-
@test_throws JuMP._logic_error_exception(:>) 1 > x
1114+
@test_throws JuMP._logic_error_exception(:<) x > 1
1115+
@test_throws JuMP._logic_error_exception(:<) 1 > x
11161116
@test_throws JuMP._logic_error_exception(:<) x < 1
11171117
@test_throws JuMP._logic_error_exception(:<) 1 < x
11181118
return

0 commit comments

Comments
 (0)