Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 5148fef

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix NFTypeCheck.matchDimensions segfault.
- Fix NFTypeCheck.matchDimensions so it actually fails when the dimensions don't match, and always assigns all outputs. Belonging to [master]: - #2065
1 parent 4d02b90 commit 5148fef

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Compiler/NFFrontEnd/NFFunction.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ uniontype Function
652652
inputnode :: inputs := inputs;
653653
comp := InstNode.component(inputnode);
654654

655-
(margexp, mty, matchKind) := TypeCheck.matchTypes(ty, Component.getType(comp), argexp);
655+
(margexp, mty, matchKind) := TypeCheck.matchTypes(ty, Component.getType(comp), argexp, allowUnknown = true);
656656
correct := TypeCheck.isCompatibleMatch(matchKind);
657657
if TypeCheck.isCastMatch(matchKind) then
658658
funcMatchKind := CAST_MATCH;

Compiler/NFFrontEnd/NFTypeCheck.mo

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,11 +1636,10 @@ algorithm
16361636
if Dimension.isEqualKnown(dim1, dim2) then
16371637
compatibleDim := dim1;
16381638
elseif allowUnknown then
1639-
if Dimension.isKnown(dim1) then
1640-
compatibleDim := dim1;
1641-
else
1642-
compatibleDim := dim2;
1643-
end if;
1639+
compatibleDim := if Dimension.isKnown(dim1) then dim1 else dim2;
1640+
else
1641+
compatibleDim := dim1;
1642+
compatible := false;
16441643
end if;
16451644
end matchDimensions;
16461645

Compiler/NFFrontEnd/NFTyping.mo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,8 @@ algorithm
20002000
(e1, ty1) := typeExp(st.lhs, st.info, ExpOrigin.LHS());
20012001
(e2, ty2) := typeExp(st.rhs, st.info, ExpOrigin.RHS());
20022002

2003-
(e2,_, mk) := TypeCheck.matchTypes(ty2, ty1, e2);
2003+
// TODO: Should probably only be allowUnknown = true if in a function.
2004+
(e2,_, mk) := TypeCheck.matchTypes(ty2, ty1, e2, allowUnknown = true);
20042005

20052006
if TypeCheck.isIncompatibleMatch(mk) then
20062007
Error.addSourceMessage(Error.ASSIGN_TYPE_MISMATCH_ERROR,

0 commit comments

Comments
 (0)