Skip to content

Commit 36c7191

Browse files
committed
Remove return after error
1 parent 4041fbe commit 36c7191

File tree

16 files changed

+3
-61
lines changed

16 files changed

+3
-61
lines changed

ext/QUBOTools_MOI/error.jl

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ end
99

1010
function qubo_parsing_error(msg::AbstractString; ads::Bool = true)
1111
throw(QUBOParsingError(msg; ads))
12-
13-
return nothing
1412
end
1513

1614
function Base.showerror(io::IO, e::QUBOParsingError)

ext/QUBOTools_MOI/model.jl

-8
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ function _parse_moi_model(::Type{T}, model::MOI.ModelLike) where {T}
5555

5656
if !_is_unconstrained(model)
5757
qubo_parsing_error("The provided model is not unconstrained.")
58-
59-
return nothing
6058
end
6159

6260
Ω = Set{VI}(MOI.get(model, MOI.ListOfVariableIndices()))
@@ -79,21 +77,15 @@ function _parse_moi_model(::Type{T}, model::MOI.ModelLike) where {T}
7977
# Assuming: 𝕊, 𝔹 ⊆ Ω
8078
if !isempty(𝕊) && !isempty(𝔹)
8179
qubo_parsing_error("The given model contains both boolean and spin variables")
82-
83-
return nothing
8480
elseif isempty(𝕊) # QUBO model?
8581
if 𝔹 != Ω
8682
qubo_parsing_error("Not all variables in the given model are boolean")
87-
88-
return nothing
8983
else
9084
return _extract_bool_model(T, model, Ω)
9185
end
9286
else # isempty(𝔹) # Ising model?
9387
if 𝕊 != Ω
9488
qubo_parsing_error("Not all variables in the given model are spin")
95-
96-
return nothing
9789
else
9890
return _extract_spin_model(T, model, Ω)
9991
end

ext/QUBOTools_MOI/sense.jl

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ function QUBOTools.sense(s::MOI.OptimizationSense)
55
return QUBOTools.sense(:max)
66
else
77
error("Invalid sense for QUBO: '$sense'")
8-
9-
return nothing
108
end
119
end

src/library/error.jl

-8
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ end
2121

2222
function solution_error(msg::Union{String,Nothing} = nothing)
2323
throw(SolutionError(msg))
24-
25-
return nothing
2624
end
2725

2826
@doc raw"""
@@ -47,8 +45,6 @@ end
4745

4846
function format_error(msg::Union{String,Nothing} = nothing)
4947
throw(FormatError(msg))
50-
51-
return nothing
5248
end
5349

5450
@doc raw"""
@@ -72,8 +68,6 @@ end
7268

7369
function syntax_error(msg::Union{String,Nothing} = nothing)
7470
throw(SyntaxError(msg))
75-
76-
return nothing
7771
end
7872

7973
function syntax_warning(msg::AbstractString)
@@ -103,8 +97,6 @@ end
10397

10498
function casting_error(msg::Union{String,Nothing} = nothing)
10599
throw(CastingError(msg))
106-
107-
return nothing
108100
end
109101

110102
function casting_error((s, t)::Route{X}, ::T) where {X,T}

src/library/form/abstract.jl

+2-6
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,11 @@ function formtype(spec::Symbol, ::Type{T} = Float64) where {T}
104104
end
105105

106106
function formtype(::Val{spec}, ::Type = Float64) where {spec}
107-
error("Unknown form type specifier '$(spec)'.")
108-
109-
return nothing
107+
error("Unknown form type specifier '$(spec)'")
110108
end
111109

112110
function formtype(::Type{spec}, ::Type = Float64) where {spec}
113-
error("Unknown form type specifier '$(spec)'.")
114-
115-
return nothing
111+
error("Unknown form type specifier '$(spec)'")
116112
end
117113

118114

src/library/form/form.jl

-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,5 @@ function cast((s, t)::Route{D}, Φ::Form{T,LF,QF}) where {D<:Domain,T,LF<:Abstra
140140
return Form{T,LF,QF}(n, L, Q, α, β; sense = sense(Φ), domain = t)
141141
else
142142
casting_error((s => t), Φ)
143-
144-
return nothing
145143
end
146144
end

src/library/format/bqpjson/format.jl

-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ function _BQPJSON_VARIABLE_DOMAIN(X::Domain)
1010
return "spin"
1111
else
1212
error("Invalid domain '$X'")
13-
14-
return nothing
1513
end
1614
end
1715

@@ -22,8 +20,6 @@ function _BQPJSON_VALIDATE_DOMAIN(x::Integer, X::Domain)
2220
return (s == ) || (s == )
2321
else
2422
error("Invalid domain '$X'")
25-
26-
return nothing
2723
end
2824
end
2925

src/library/format/qubist/parser.jl

-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ function _parse_line!(data::Dict{Symbol,Any}, line::AbstractString, fmt::Qubist)
2424
_parse_header!(data, line, fmt) && return nothing
2525

2626
syntax_error("'$line'")
27-
28-
return nothing
2927
end
3028

3129
function _parse_entry!(data::Dict{Symbol,Any}, line::AbstractString, ::Qubist)

src/library/format/qubo/format.jl

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ struct QUBO <: AbstractFormat
1313
elseif style === :mqlib
1414
return new(:mqlib)
1515
else
16-
error("Unkown style '$style' for QUBO files. Options are: ':dwave', ':qbsolv' and ':mqlib'.")
17-
18-
return nothing
16+
error("Unkown style '$style' for QUBO files. Options are: ':dwave', ':qbsolv' and ':mqlib'")
1917
end
2018
end
2119
end

src/library/format/qubo/parser.jl

-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ function _parse_line!(data::Dict{Symbol,Any}, line::AbstractString, fmt::QUBO)
3838
_parse_header!(data, line, fmt, Val(fmt.style)) && return nothing
3939

4040
syntax_error("$line")
41-
42-
return nothing
4341
end
4442

4543
function _parse_entry!(

src/library/frame.jl

-8
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ function sense(s::Symbol)
77
return Max
88
else
99
error("Invalid sense '$s', options are ':min' and ':max'")
10-
11-
return nothing
1210
end
1311
end
1412

@@ -21,8 +19,6 @@ function Base.Symbol(s::Sense)
2119
return :max
2220
else
2321
error("Invalid sense '$s', options are 'Min' and 'Max'")
24-
25-
return nothing
2622
end
2723
end
2824

@@ -37,8 +33,6 @@ function domain(x::Symbol)
3733
return SpinDomain
3834
else
3935
error("Invalid domain '$x', options are ':bool' and ':spin'")
40-
41-
return nothing
4236
end
4337
end
4438

@@ -51,8 +45,6 @@ function Base.Symbol(x::Domain)
5145
return :spin
5246
else
5347
error("Invalid domain '$x', options are 'BoolDomain' and 'SpinDomain'")
54-
55-
return nothing
5648
end
5749
end
5850

src/library/model/abstract.jl

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ function variable(model::AbstractModel{V}, i::Integer) where {V}
2121
return mapping[i]
2222
else
2323
error("Variable with index '$i' does not belong to the model")
24-
25-
return nothing
2624
end
2725
end
2826

src/library/model/model.jl

-4
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ function index(model::Model{V}, v::V) where {V}
183183
return index(model.variable_map, v)
184184
else
185185
error("Variable '$v' does not belong to the model")
186-
187-
return nothing
188186
end
189187
end
190188

@@ -208,8 +206,6 @@ solution(model::Model) = model.solution
208206
function start(model::Model{V,T,U}, i::Integer; domain = QUBOTools.domain(model)) where {V,T,U}
209207
if !hasindex(model, i)
210208
error("Index '$i' is out of bounds [1, $(dimension(model))]")
211-
212-
return nothing
213209
elseif haskey(model.start, i)
214210
return cast((QUBOTools.domain(model) => QUBOTools.domain(domain)), model.start[i])
215211
else

src/library/model/variable_map.jl

-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ function index(vm::VariableMap{V}, v::V) where {V}
3535
return vm.map[v]
3636
else
3737
error("Variable '$v' does not belong to the mapping")
38-
39-
return nothing
4038
end
4139
end
4240

@@ -47,7 +45,5 @@ function variable(vm::VariableMap, i::Integer)
4745
return vm.inv[i]
4846
else
4947
error("Variable index '$i' is out of range '[1, $n]'")
50-
51-
return nothing
5248
end
5349
end

src/library/solution/abstract.jl

-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ function sample(sol::AbstractSolution, i::Integer)
3838
return getindex(sol, i)
3939
else
4040
error("Sample with index '$i' does not belong to the solution")
41-
42-
return nothing
4341
end
4442
end
4543

src/library/solution/sampleset.jl

-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,5 @@ function cast((s,t)::Route{D}, sol::SampleSet{T,U}) where {T,U,D<:Domain}
132132
)
133133
else
134134
casting_error(s => t, sol)
135-
136-
return nothing
137135
end
138136
end

0 commit comments

Comments
 (0)