diff --git a/.github/workflows/aqua.yml b/.github/workflows/aqua.yml new file mode 100644 index 0000000000..08560ac2f4 --- /dev/null +++ b/.github/workflows/aqua.yml @@ -0,0 +1,23 @@ +name: aqua-lint +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: julia-actions/setup-julia@latest + with: + version: '1' + - uses: actions/checkout@v1 + - name: Aqua + shell: julia --color=yes {0} + run: | + using Pkg + Pkg.add(PackageSpec(name="Aqua")) + Pkg.develop(PackageSpec(path=pwd())) + using MathOptInterface, Aqua + Aqua.test_all(MathOptInterface; ambiguities = false) diff --git a/src/Utilities/cachingoptimizer.jl b/src/Utilities/cachingoptimizer.jl index faf4b56ec9..f05bba295f 100644 --- a/src/Utilities/cachingoptimizer.jl +++ b/src/Utilities/cachingoptimizer.jl @@ -54,7 +54,7 @@ A `CachingOptimizer` may be in one of three possible states * `ATTACHED_OPTIMIZER`: The CachingOptimizer has an optimizer, and it is synchronized with the cached model. -### modes +### Modes A `CachingOptimizer` has two modes of operation (`CachingOptimizerMode`): diff --git a/src/Utilities/functions.jl b/src/Utilities/functions.jl index 8c67f3879f..a422a5e190 100644 --- a/src/Utilities/functions.jl +++ b/src/Utilities/functions.jl @@ -2193,8 +2193,15 @@ function operate( return operate!(op, T, copy(f), g) end -function Base.:+(args::VectorLike{T}...) where {T} - return operate(+, T, args...) +function Base.:+(arg::VectorLike, args::VectorLike...) + T = _eltype(arg, args) + if T === nothing + error( + "Cannot add VectorOfVariables together without a coefficient " * + "type. Convert one argument to a VectorAffineFunction first.", + ) + end + return operate(+, T, arg, args...) end # Base.:+(α::Vector{T}, f::VectorLike{T}...) is too general as it also covers @@ -2207,8 +2214,15 @@ function Base.:+(f::VectorLike{T}, α::Vector{T}) where {T} return operate(+, T, f, α) end -function Base.:-(args::VectorLike{T}...) where {T} - return operate(-, T, args...) +function Base.:-(arg::VectorLike, args::VectorLike...) + T = _eltype(arg, args) + if T === nothing + error( + "Cannot subtract VectorOfVariables without a coefficient " * + "type. Convert one argument to a VectorAffineFunction first.", + ) + end + return operate(-, T, arg, args...) end function Base.:-(f::VectorLike{T}, α::Vector{T}) where {T}