@@ -1645,33 +1645,36 @@ algorithm
16451645end typeSections;
16461646
16471647function typeExternalArg
1648- input output Expression arg;
1648+ input Expression arg;
16491649 input SourceInfo info;
16501650 input InstNode node;
1651+ output Expression outArg;
16511652protected
16521653 Type ty;
16531654 Variability var ;
16541655algorithm
1655- (arg , ty, var ) := typeExp(arg, info);
1656+ (outArg , ty, var ) := typeExp(arg, info);
16561657
16571658 // Check that the external function argument is valid. The valid types of
16581659 // expressions are crefs, scalar constants and size expressions with constant
1659- // index. Size expressions with constant index are evaluated when they are
1660- // typed, so we need only care about the first two types of expressions here.
1661- arg := match arg
1662- case Expression . CREF () then arg;
1660+ // index. The reason why we match on the untyped expression here is because
1661+ // size expressions might be evaluated during typing, but the variability
1662+ // would still be parameter in that case.
1663+ outArg := match arg
1664+ case Expression . CREF () then outArg;
1665+ case Expression . SIZE () guard var <= Variability . PARAMETER then outArg;
16631666 else
16641667 algorithm
16651668 if Type . isScalarBuiltin(ty) and var == Variability . CONSTANT then
1666- arg := Ceval . evalExp(arg , Ceval . EvalTarget . IGNORE_ERRORS ());
1667- arg := SimplifyExp . simplifyExp(arg);
1669+ outArg := Ceval . evalExp(outArg , Ceval . EvalTarget . IGNORE_ERRORS ());
1670+ outArg := SimplifyExp . simplifyExp(arg);
16681671 else
16691672 Error . addSourceMessage(Error . EXTERNAL_ARG_WRONG_EXP ,
1670- {Expression . toString(arg )}, info);
1673+ {Expression . toString(outArg )}, info);
16711674 fail();
16721675 end if ;
16731676 then
1674- arg ;
1677+ outArg ;
16751678
16761679 end match;
16771680end typeExternalArg;
0 commit comments