Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw informative error when parsing reference sets in macros #3653

Merged
merged 4 commits into from
Jan 16, 2024

Conversation

odow
Copy link
Member

@odow odow commented Jan 15, 2024

Closes #3652

Error from #3652 is now:

julia> using JuMP

julia> model = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> @variable(model, a, Int)
a

julia> @variable(model, b[1:a], Int) 
ERROR: At REPL[67]:1: `@variable(model, b[1:a], Int)`: unexpected error parsing reference set: 1:a
Stacktrace:
 [1] error(::String, ::String, ::Expr)
   @ Base ./error.jl:44
 [2] (::JuMP.Containers.var"#error_fn#98"{String})(::String, ::Vararg{Any})
   @ JuMP.Containers ~/.julia/dev/JuMP/src/Containers/macro.jl:315
 [3] macro expansion
   @ ~/.julia/dev/JuMP/src/Containers/macro.jl:92 [inlined]
 [4] macro expansion
   @ ~/.julia/dev/JuMP/src/macros.jl:375 [inlined]
 [5] top-level scope
   @ REPL[67]:1

caused by: MethodError: no method matching (::Colon)(::Int64, ::VariableRef)

Closest candidates are:
  (::Colon)(::T, ::Any, ::T) where T<:Real
   @ Base range.jl:50
  (::Colon)(::A, ::Any, ::C) where {A<:Real, C<:Real}
   @ Base range.jl:10
  (::Colon)(::T, ::Any, ::T) where T
   @ Base range.jl:49
  ...

Stacktrace:
 [1] macro expansion
   @ ~/.julia/dev/JuMP/src/Containers/macro.jl:90 [inlined]
 [2] macro expansion
   @ ~/.julia/dev/JuMP/src/macros.jl:375 [inlined]
 [3] top-level scope
   @ REPL[67]:1

cc @LebedevRI

@LebedevRI
Copy link
Contributor

Nice! Thank you!

Copy link

codecov bot commented Jan 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b026f67) 98.28% compared to head (f90845f) 98.28%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3653   +/-   ##
=======================================
  Coverage   98.28%   98.28%           
=======================================
  Files          43       43           
  Lines        5640     5650   +10     
=======================================
+ Hits         5543     5553   +10     
  Misses         97       97           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@odow odow merged commit c31d9cf into master Jan 16, 2024
12 checks passed
@odow odow deleted the od/error-fn-ref-sets branch January 16, 2024 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Diagnostics request: using variable in variable container bounds
2 participants