JuMP and user defined objective function: JuMPArray dimension problem

Edit: I changed JuMP.register(m, :C2ND_min, 2, C2ND_min, autodiff=true) to JuMP.register(m, :C2ND_min, 2, C2ND_min, autodiff = :forward) and the StackOverflowError: disappeared. Would anyone know why this happened? I am happy the error is gone but it would be useful for future codes to understand why.

However, the if conditional evaluation is now creating some problems giving an error saying (from what I understand after reading the documentation) that the condition is not of type Bool but of type Symbol which I fail to understand as i tested on simpler function that if isinf(θhigh) || isnan(θhigh) returns either true or false?

TypeError: non-boolean (Symbol) used in boolean context

Stacktrace:
 [1] (::getfield(JuMP, Symbol("#kw##register")))(::NamedTuple{(:autodiff,),Tuple{Symbol}}, ::typeof(JuMP.register), ::Model, ::Symbol, ::Int32, ::Function) at .\none:0
 [2] macro expansion at C:\Users\arquie\.julia\packages\JuMP\Xvn0n\src\macros.jl:339 [inlined]
 [3] model_creator(::Float64) at .\In[15]:68
 [4] top-level scope at In[15]:95