diff --git a/src/macros/@constraint.jl b/src/macros/@constraint.jl index b33468c587b..bc0feeb03a8 100644 --- a/src/macros/@constraint.jl +++ b/src/macros/@constraint.jl @@ -655,7 +655,7 @@ function parse_constraint_call( ) f, parse_code = _rewrite_expression(func) build_call = if vectorized - :(build_constraint.($error_fn, _desparsify($f), Ref($(esc(set))))) + :(build_constraint.($error_fn, _desparsify($f), $(esc(set)))) else :(build_constraint($error_fn, $f, $(esc(set)))) end diff --git a/test/test_macros.jl b/test/test_macros.jl index ea2c31eb46e..b0ed162f78b 100644 --- a/test/test_macros.jl +++ b/test/test_macros.jl @@ -2210,4 +2210,17 @@ function test_base_name_escape() return end +function test_constraint_broadcast_in_set() + model = Model() + @variable(model, x[1:2]) + sets = [MOI.GreaterThan(1.0), MOI.GreaterThan(2.0)] + c = @constraint(model, 1.0 * x .∈ sets) + @test constraint_object(c[1]).set == MOI.GreaterThan(1.0) + @test constraint_object(c[2]).set == MOI.GreaterThan(2.0) + c = @constraint(model, 1.0 * x .∈ MOI.ZeroOne()) + @test constraint_object(c[1]).set == MOI.ZeroOne() + @test constraint_object(c[2]).set == MOI.ZeroOne() + return +end + end # module