Skip to content

Commit a171233

Browse files
fixup! fix: fix parameter default parsing in @mtkmodel
1 parent 796899e commit a171233

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/systems/model_parsing.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -376,40 +376,40 @@ Base.@nospecializeinfer function parse_variable_def!(
376376
Meta.isexpr(a, :call) &&
377377
assert_unique_independent_var(dict, a.args[end])
378378
var = :($varname = $varname === $NO_VALUE ? $val : $varname;
379-
$varname = $first(@parameters ($a[$(indices...)]::$type = $varval),
379+
$varname = $first(@parameters ($a[$(indices...)]::$type = $no_value_default_to_nothing($varval)),
380380
$(def_n_meta...)))
381381
elseif varclass == :constants
382382
Meta.isexpr(a, :call) &&
383383
assert_unique_independent_var(dict, a.args[end])
384384
var = :($varname = $varname === $NO_VALUE ? $val : $varname;
385-
$varname = $first(@constants ($a[$(indices...)]::$type = $varval),
385+
$varname = $first(@constants ($a[$(indices...)]::$type = $no_value_default_to_nothing($varval)),
386386
$(def_n_meta...)))
387387
else
388388
Meta.isexpr(a, :call) ||
389389
throw("$a is not a variable of the independent variable")
390390
assert_unique_independent_var(dict, a.args[end])
391391
var = :($varname = $varname === $NO_VALUE ? $val : $varname;
392392
$varname = $first(@variables $a[$(indices...)]::$type = (
393-
$varval),
393+
$no_value_default_to_nothing($varval)),
394394
$(def_n_meta...)))
395395
end
396396
else
397397
if varclass == :parameters
398398
Meta.isexpr(a, :call) &&
399399
assert_unique_independent_var(dict, a.args[end])
400400
var = :($varname = $varname === $NO_VALUE ? $def_n_meta : $varname;
401-
$varname = $first(@parameters $a[$(indices...)]::$type = $varname))
401+
$varname = $first(@parameters $a[$(indices...)]::$type = $no_value_default_to_nothing($varname)))
402402
elseif varclass == :constants
403403
Meta.isexpr(a, :call) &&
404404
assert_unique_independent_var(dict, a.args[end])
405405
var = :($varname = $varname === $NO_VALUE ? $def_n_meta : $varname;
406-
$varname = $first(@constants $a[$(indices...)]::$type = $varname))
406+
$varname = $first(@constants $a[$(indices...)]::$type = $no_value_default_to_nothing($varname)))
407407
else
408408
Meta.isexpr(a, :call) ||
409409
throw("$a is not a variable of the independent variable")
410410
assert_unique_independent_var(dict, a.args[end])
411411
var = :($varname = $varname === $NO_VALUE ? $def_n_meta : $varname;
412-
$varname = $first(@variables $a[$(indices...)]::$type = $varname))
412+
$varname = $first(@variables $a[$(indices...)]::$type = $no_value_default_to_nothing($varname)))
413413
end
414414
varval, meta = def_n_meta, nothing
415415
end
@@ -432,15 +432,15 @@ Base.@nospecializeinfer function parse_variable_def!(
432432
varname = a isa Expr && a.head == :call ? a.args[1] : a
433433
if varclass == :parameters
434434
Meta.isexpr(a, :call) && assert_unique_independent_var(dict, a.args[end])
435-
var = :($varname = $first(@parameters $a[$(indices...)]::$type = $varname))
435+
var = :($varname = $first(@parameters $a[$(indices...)]::$type = $no_value_default_to_nothing($varname)))
436436
elseif varclass == :constants
437437
Meta.isexpr(a, :call) && assert_unique_independent_var(dict, a.args[end])
438-
var = :($varname = $first(@constants $a[$(indices...)]::$type = $varname))
438+
var = :($varname = $first(@constants $a[$(indices...)]::$type = $no_value_default_to_nothing($varname)))
439439
elseif varclass == :variables
440440
Meta.isexpr(a, :call) ||
441441
throw("$a is not a variable of the independent variable")
442442
assert_unique_independent_var(dict, a.args[end])
443-
var = :($varname = $first(@variables $a[$(indices...)]::$type = $varname))
443+
var = :($varname = $first(@variables $a[$(indices...)]::$type = $no_value_default_to_nothing($varname)))
444444
else
445445
throw("Symbolic array with arbitrary length is not handled for $varclass.
446446
Please open an issue with an example.")

0 commit comments

Comments
 (0)