Skip to content

Commit

Permalink
Fix @constraintref for JuMPArray (#1330)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat authored and mlubin committed Jun 8, 2018
1 parent d381446 commit 02b12a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ macro constraintref(var)
idxpairs = IndexPair[]

code = quote
$(esc(gendict(varname, :ConstraintRef, idxsets...)))
$(gendict(esc(varname), :ConstraintRef, esc.(idxsets)...))
nothing
end
return code
Expand Down
7 changes: 7 additions & 0 deletions test/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,11 @@ end
@test typeof(Y) == SparseMatrixCSC{Float64, Int}
@test Y == sparse([1, 3], [2, 3], [1, 2])
end

@testset "@constraintref does not work with JuMPArray #1329" begin
m = Model()
cities = [:LA, :NY]
@constraintref cref[cities]
@test cref.indexsets[1] == cities
end
end

0 comments on commit 02b12a1

Please sign in to comment.