Skip to content

Commit

Permalink
[NF] Fix typing of when statements too.
Browse files Browse the repository at this point in the history
- Use correct origin when typing when-conditions in statements.
- Propagate the when-flag properly when marking variables inside
  when-clauses as discrete.

Belonging to [master]:
  - OpenModelica/OMCompiler#2781
  - OpenModelica/OpenModelica-testsuite#1074
  • Loading branch information
perost authored and OpenModelica-Hudson committed Nov 9, 2018
1 parent 088d435 commit 13a4ae4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Compiler/NFFrontEnd/NFInst.mo
Expand Up @@ -3119,7 +3119,7 @@ algorithm
all_params := false;
end if;

updateImplicitVariabilityEql(branch.body);
updateImplicitVariabilityEql(branch.body, inWhen);
then
();
end match;
Expand Down Expand Up @@ -3178,7 +3178,7 @@ algorithm
// 'when' is not allowed in 'for', so we only need to keep going if
// we're already in a 'when'.
if inWhen then
updateImplicitVariabilityStmts(stmt.body);
updateImplicitVariabilityStmts(stmt.body, true);
end if;
then
();
Expand All @@ -3189,7 +3189,7 @@ algorithm
// we're already in a 'when.
if inWhen then
for branch in stmt.branches loop
updateImplicitVariabilityStmts(Util.tuple22(branch));
updateImplicitVariabilityStmts(Util.tuple22(branch), true);
end for;
end if;
then
Expand All @@ -3208,7 +3208,7 @@ algorithm
// 'when' is not allowed in 'while', so we only need to keep going if
// we're already in a 'when.
if inWhen then
updateImplicitVariabilityStmts(stmt.body);
updateImplicitVariabilityStmts(stmt.body, true);
end if;
then
();
Expand Down
2 changes: 1 addition & 1 deletion Compiler/NFFrontEnd/NFTyping.mo
Expand Up @@ -2685,7 +2685,7 @@ algorithm
tybrs := list(
match br case(cond, body)
algorithm
e1 := typeCondition(cond, next_origin, st.source, Error.WHEN_CONDITION_TYPE_ERROR, allowVector = true);
e1 := typeCondition(cond, origin, st.source, Error.WHEN_CONDITION_TYPE_ERROR, allowVector = true);
sts1 := list(typeStatement(bst, next_origin) for bst in body);
then (e1, sts1);
end match
Expand Down

0 comments on commit 13a4ae4

Please sign in to comment.