@@ -232,55 +232,56 @@ function parse_variable_def!(dict, mod, arg, varclass, kwargs, where_types;
232
232
varclass, where_types, meta)
233
233
return var, def, Dict ()
234
234
end
235
- Expr (:tuple , Expr (:ref , a, b... ), y) || Expr (:tuple , Expr (:( :: ), Expr ( : ref , a, b... ), n ), y) => begin
236
- isdefined (mod, :n ) || (n = Real)
235
+ Expr (:tuple , Expr (:( :: ), Expr ( : ref , a, b... ), type), y) || Expr (:tuple , Expr (:ref , a, b... ), y) => begin
236
+ ( @isdefined type ) || (type = Real)
237
237
varname = Meta. isexpr (a, :call ) ? a. args[1 ] : a
238
238
push! (kwargs, Expr (:kw , varname, nothing ))
239
239
varval = unit_handled_variable_value (mod, y, varname)
240
240
if varclass == :parameters
241
- var = :($ varname = $ first (@parameters $ a[$ (b... )]:: $n = ($ varval, $ y)))
241
+ var = :($ varname = $ first (@parameters $ a[$ (b... )]:: $type = ($ varval, $ y)))
242
242
else
243
- var = :($ varname = $ first (@variables $ a[$ (b... )]:: $n = ($ varval, $ y)))
243
+ var = :($ varname = $ first (@variables $ a[$ (b... )]:: $type = ($ varval, $ y)))
244
244
end
245
245
# TODO : update `dict` aka `Model.structure` with the metadata
246
246
(:($ varname... ), var), nothing , Dict ()
247
247
end
248
- Expr (:(= ), Expr (:ref , a, b... ), y) || Expr (:(= ), Expr (:( :: ), Expr ( : ref , a, b... ), n ), y) => begin
249
- isdefined (mod, :n ) || (n = Real)
248
+ Expr (:(= ), Expr (:( :: ), Expr ( : ref , a, b... ), type), y) || Expr (:(= ), Expr (:ref , a, b... ), y) => begin
249
+ ( @isdefined type ) || (type = Real)
250
250
varname = Meta. isexpr (a, :call ) ? a. args[1 ] : a
251
251
if Meta. isexpr (y, :tuple )
252
252
varval = unit_handled_variable_value (mod, y, varname)
253
253
val, y = (y. args[1 ], y. args[2 : end ])
254
254
push! (kwargs, Expr (:kw , varname, nothing ))
255
255
if varclass == :parameters
256
256
var = :($ varname = $ varname === nothing ? $ val : $ varname;
257
- $ varname = $ first (@parameters $ a[$ (b... )]:: $n = (
257
+ $ varname = $ first (@parameters $ a[$ (b... )]:: $type = (
258
258
$ varval, $ (y... ))))
259
259
else
260
260
var = :($ varname = $ varname === nothing ? $ val : $ varname;
261
- $ varname = $ first (@variables $ a[$ (b... )]:: $n = (
261
+ $ varname = $ first (@variables $ a[$ (b... )]:: $type = (
262
262
$ varval, $ (y... ))))
263
263
end
264
264
else
265
265
push! (kwargs, Expr (:kw , varname, nothing ))
266
266
if varclass == :parameters
267
267
var = :($ varname = $ varname === nothing ? $ y : $ varname;
268
- $ varname = $ first (@parameters $ a[$ (b... )]:: $n = $ varname))
268
+ $ varname = $ first (@parameters $ a[$ (b... )]:: $type = $ varname))
269
269
else
270
270
var = :($ varname = $ varname === nothing ? $ y : $ varname;
271
- $ varname = $ first (@variables $ a[$ (b... )]:: $n = $ varname))
271
+ $ varname = $ first (@variables $ a[$ (b... )]:: $type = $ varname))
272
272
end
273
273
end
274
274
# TODO : update `dict`` aka `Model.structure` with the metadata
275
275
(:($ varname... ), var), nothing , Dict ()
276
276
end
277
- Expr (:ref , a, b... ) => begin
277
+ Expr (:(:: ), Expr (:ref , a, b... ), type) || Expr (:ref , a, b... ) => begin
278
+ (@isdefined type) || (type = Real)
278
279
varname = a isa Expr && a. head == :call ? a. args[1 ] : a
279
280
push! (kwargs, Expr (:kw , varname, nothing ))
280
281
if varclass == :parameters
281
- var = :($ varname = $ first (@parameters $ a[$ (b... )] = $ varname))
282
+ var = :($ varname = $ first (@parameters $ a[$ (b... )]:: $type = $ varname))
282
283
elseif varclass == :variables
283
- var = :($ varname = $ first (@variables $ a[$ (b... )] = $ varname))
284
+ var = :($ varname = $ first (@variables $ a[$ (b... )]:: $type = $ varname))
284
285
else
285
286
throw (" Symbolic array with arbitrary length is not handled for $varclass .
286
287
Please open an issue with an example." )
0 commit comments