Skip to content

Commit

Permalink
Merge 6b093f8 into 64fc678
Browse files Browse the repository at this point in the history
  • Loading branch information
mlubin committed Jul 29, 2018
2 parents 64fc678 + 6b093f8 commit a5c1418
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/macros.jl
Expand Up @@ -1444,22 +1444,26 @@ macro NLparameter(m, ex, extra...)

extra, kwargs, requestedcontainer = extract_kwargs(extra)
(length(extra) == 0 && length(kwargs) == 0) || error("in @NLperameter: too many arguments.")
m = esc(m)
@assert isexpr(ex, :call)
@assert length(ex.args) == 3
@assert ex.args[1] == :(==)
if !isexpr(ex, :call) || length(ex.args) != 3 || ex.args[1] != :(==)
error("In @NLparameter($m, $ex): syntax error.")
end
c = ex.args[2]
x = ex.args[3]

anonvar = isexpr(c, :vect) || isexpr(c, :vcat)
if anonvar
error("In @NLparameter($m, $ex): Anonymous nonlinear parameter syntax is not currently supported")
end
m = esc(m)
variable = gensym()
escvarname = anonvar ? variable : esc(getname(c))

refcall, idxvars, idxsets, condition = buildrefsets(c, variable)
code = quote
if !isa($(esc(x)), Number)
error(string("in @NLparameter (", $(string(ex)), "): expected ",
$(string(x))," to be a number."))
end
$(refcall) = newparameter($m, $(esc(x)))
end
return assert_validmodel(m, quote
Expand Down

0 comments on commit a5c1418

Please sign in to comment.