I have a template like:
template register*( val: float;
caus:Option[Causality] = none(Causality); #cLocal;
varia:Option[Variability] = none(Variability); #vContinuous;
ini:Option[Initial] = none(Initial); #iUnset;
desc:Option[string] = none(string);
derivative:Option[uint] = none( uint );
start: Option[float] = none(float) ) {.dirty.} =
if val.type.name == "float":
var p = Param(kind: tReal)
p.name = val.astToStr
p.idx = nParamsR
p.addressR = addr(val)
p.causality = caus
p.variability = varia
p.initial = ini
p.description = desc
p.derivative = derivative
p.start = start.get
static: nParamsR += 1
params.add p
and when I call it with:
fmu( "dq", "{8c4e810f-3df3-4a00-8276-176fa3c9f000}"):
var x:float = 1.0
register( x, caus = cLocal.some,
varia = vContinuous.some, ini = iExact.some,
desc = "the only state".some,
derivative = 0.uint.some )
I get the error:
Error: in expression 'p.some(n)': identifier expected, but found 'some(n)'
on the line that contains: derivative = 0.uint.some.
What could be the reason?
This is with template substitution this line
p.derivative = derivative
becomes
p.0.uint.some = 0.uint.some
Don't name your template parameter the same as an object field.