@@ -300,7 +300,7 @@ uniontype Function
300300 case CachedData . FUNCTION () then (fn_node, cache. specialBuiltin);
301301 else algorithm
302302 (fn_node, specialBuiltin) := instFunc2(ComponentRef . toPath(fn_ref), fn_node, info);
303- instFuncExpressions(fn_node);
303+ // instFuncExpressions(fn_node);
304304 then (fn_node, specialBuiltin);
305305 end match;
306306 end instFuncRef;
@@ -357,6 +357,8 @@ uniontype Function
357357 algorithm
358358 // fnNode := InstNode.setNodeType(NFInstNode.InstNodeType.ROOT_CLASS(), fnNode);
359359 fnNode := Inst . instantiate(fnNode);
360+ InstNode . cacheInitFunc(fnNode);
361+ Inst . instExpressions(fnNode);
360362 fnNode := Record . instConstructors(fnPath, fnNode, info);
361363 then
362364 (fnNode, false );
@@ -365,6 +367,8 @@ uniontype Function
365367 algorithm
366368 // fnNode := InstNode.setNodeType(NFInstNode.InstNodeType.ROOT_CLASS(), fnNode);
367369 fnNode := Inst . instantiate(fnNode);
370+ InstNode . cacheInitFunc(fnNode);
371+ Inst . instExpressions(fnNode);
368372 fnNode := Record . instOperatorFunctions(fnNode, info);
369373 then
370374 (fnNode, false );
@@ -385,6 +389,10 @@ uniontype Function
385389 algorithm
386390 fnNode := InstNode . setNodeType(NFInstNode . InstNodeType . ROOT_CLASS (), fnNode);
387391 fnNode := Inst . instantiate(fnNode);
392+ // Set up an empty function cache to signal that this function is
393+ // currently being instantiated, so recursive functions can be handled.
394+ InstNode . cacheInitFunc(fnNode);
395+ Inst . instExpressions(fnNode);
388396 fn := Function . new(fnPath, fnNode);
389397 specialBuiltin := isSpecialBuiltin(fn);
390398 fnNode := InstNode . cacheAddFunc(fnNode, fn, specialBuiltin);
@@ -1151,17 +1159,21 @@ protected
11511159 input output list< InstNode > locals = {};
11521160 protected
11531161 Class cls;
1154- array< Mutable < InstNode > > comps;
1162+ array< InstNode > comps;
11551163 InstNode n;
11561164 algorithm
11571165 Error . assertion(InstNode . isClass(node), getInstanceName() + " got non-class node" , sourceInfo());
11581166 cls := InstNode . getClass(node);
11591167
11601168 () := match cls
1161- case Class . EXPANDED_CLASS (elements = ClassTree . INSTANTIATED_TREE (components = comps))
1169+ case Class . INSTANCED_CLASS (elements = ClassTree . FLAT_TREE (components = comps))
11621170 algorithm
11631171 for i in arrayLength(comps):-1 :1 loop
1164- n := Mutable . access(comps[i]);
1172+ n := comps[i];
1173+
1174+ if InstNode . isEmpty(n) then
1175+ continue ;
1176+ end if ;
11651177
11661178 // Sort the components based on their direction.
11671179 () := match paramDirection(n)
0 commit comments