Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release notes

## Version 0.10.6 (2026-07-30)

### Bug fixes

* Fixed the variable name-collision guard in `variables_elements` and `variables_element_ext_data` to match the updated JuMP error message:
* JuMP changed the wording from "is already attached to this model." to "is already registered in this model.".
* Both variants are now accepted for cross-version compatibility.

## Version 0.10.5 (2026-06-28)

* Increased robustness for checking whether a `TimeProfile` is of the correct type for indexing.
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "EnergyModelsBase"
uuid = "5d7e687e-f956-46f3-9045-6f5a5fd49f50"
authors = ["Lars Hellemo <Lars.Hellemo@sintef.no>, Julian Straus <Julian.Straus@sintef.no>"]
version = "0.10.5"
version = "0.10.6"

[deps]
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
Expand Down
18 changes: 12 additions & 6 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,14 @@ function variables_elements(m, 𝒳::Vector{<:AbstractElement}, 𝒳ᵛᵉᶜ,
try
variables_element(m, 𝒳ˢᵘᵇ, 𝒯, modeltype)
catch e
# Parts of the exception message we are looking for.
# Parts of the exception message we are looking for. JuMP changed the wording
# from "is already attached to this model." to "is already registered in this
# model.", so both variants are accepted for cross-version compatibility.
pre1 = "An object of name"
pre2 = "is already attached to this model."
pre2a = "is already attached to this model."
pre2b = "is already registered in this model."
if isa(e, ErrorException)
if occursin(pre1, e.msg) && occursin(pre2, e.msg)
if occursin(pre1, e.msg) && (occursin(pre2a, e.msg) || occursin(pre2b, e.msg))
# 𝒳ˢᵘᵇ was already registered by a call to a supertype, so just continue.
continue
end
Expand Down Expand Up @@ -480,11 +483,14 @@ function variables_element_ext_data(
try
variables_ext_data(m, data_type, 𝒳ᵈᵃᵗ, 𝒯, 𝒫, modeltype)
catch e
# Parts of the exception message we are looking for
# Parts of the exception message we are looking for. JuMP changed the wording
# from "is already attached to this model." to "is already registered in this
# model.", so both variants are accepted for cross-version compatibility.
pre1 = "An object of name"
pre2 = "is already attached to this model."
pre2a = "is already attached to this model."
pre2b = "is already registered in this model."
if isa(e, ErrorException)
if occursin(pre1, e.msg) && occursin(pre2, e.msg)
if occursin(pre1, e.msg) && (occursin(pre2a, e.msg) || occursin(pre2b, e.msg))
# data_type was already registered by a call to a supertype, so just continue.
continue
end
Expand Down
9 changes: 6 additions & 3 deletions test/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
# changes, we must change how variables are created.
@test isa(e, ErrorException)

# Check that the error message is not changed.
# Check that the error message matches what `variables_elements` looks for. JuMP
# changed the wording from "is already attached to this model." to "is already
# registered in this model.", so both variants are accepted.
pre1 = "An object of name"
pre2 = "is already attached to this model."
pre2a = "is already attached to this model."
pre2b = "is already registered in this model."
@test occursin(pre1, e.msg)
@test occursin(pre2, e.msg)
@test occursin(pre2a, e.msg) || occursin(pre2b, e.msg)
end
end

Expand Down
Loading