Skip to content

Commit 49960b0

Browse files
committed
partial fix for #5431, do not fail for bogus DynamicSelect dynamic part
1 parent 791fc8d commit 49960b0

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

OMCompiler/Compiler/NFFrontEnd/NFBuiltinCall.mo

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,17 @@ protected
18821882
{expStatic, expDynamic} := list(Expression.unbox(arg) for arg in args);
18831883
(arg1, ty1, var1) := Typing.typeExp(expStatic, origin, info);
18841884
arg1 := ExpandExp.expand(arg1);
1885-
(arg2, ty2, var2) := Typing.typeExp(expDynamic, origin, info);
1885+
1886+
// if we cannot typecheck the dynamic part, ignore it!
1887+
// https://trac.openmodelica.org/OpenModelica/ticket/5631
1888+
try
1889+
(arg2, ty2, var2) := Typing.typeExp(expDynamic, origin, info);
1890+
else
1891+
variability := var1;
1892+
callExp := arg1;
1893+
return;
1894+
end try;
1895+
18861896
arg2 := ExpandExp.expand(arg2);
18871897
ty := ty1;
18881898
variability := var2;

OMCompiler/Compiler/NFFrontEnd/NFCall.mo

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ protected
4343
import BuiltinCall = NFBuiltinCall;
4444
import Ceval = NFCeval;
4545
import ComponentRef = NFComponentRef;
46+
import Config;
4647
import Dimension = NFDimension;
4748
import ErrorExt;
4849
import Inline = NFInline;
@@ -847,10 +848,29 @@ protected
847848
ComponentRef fn_ref;
848849
list<Expression> args;
849850
list<NamedArg> named_args;
851+
String name;
850852
algorithm
851-
(args, named_args) := instArgs(functionArgs, scope, info);
852853

853-
callExp := match AbsynUtil.crefFirstIdent(functionName)
854+
name := AbsynUtil.crefFirstIdent(functionName);
855+
856+
// try to inst the parameters
857+
try
858+
(args, named_args) := instArgs(functionArgs, scope, info);
859+
else
860+
// didn't work, is this DynamicSelect dynamic part?! #5631
861+
if Config.getGraphicsExpMode() and stringEq(name, "DynamicSelect") then
862+
// return just the first part of DynamicSelect
863+
callExp := match functionArgs
864+
case Absyn.FUNCTIONARGS() then
865+
Inst.instExp(listHead(functionArgs.args), scope, info);
866+
end match;
867+
return;
868+
else
869+
fail();
870+
end if;
871+
end try;
872+
873+
callExp := match name
854874
// size creates Expression.SIZE instead of Expression.CALL.
855875
case "size" then BuiltinCall.makeSizeExp(args, named_args, info);
856876
// array() call with no iterators creates Expression.ARRAY instead of Expression.CALL.
@@ -862,6 +882,7 @@ protected
862882
fn_ref := Function.instFunction(functionName,scope,info);
863883
then
864884
Expression.CALL(UNTYPED_CALL(fn_ref, args, named_args, scope));
885+
865886
end match;
866887
end instNormalCall;
867888

0 commit comments

Comments
 (0)