forked from OpenModelica/OpenModelica
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add error for assignment of iterator (OpenModelica#12591)
- Add error message for assigning for an iterator inside a for-loop. - Improve the error message for using reinit on an iterator. Fixes OpenModelica#12585
- Loading branch information
Showing
6 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
testsuite/flattening/modelica/scodeinst/ForStatementAssign1.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// name: ForStatementAssign1 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
model ForStatementAssign1 | ||
algorithm | ||
for i in 1:2 loop | ||
i := 1; | ||
end for; | ||
end ForStatementAssign1; | ||
|
||
// Result: | ||
// Error processing file: ForStatementAssign1.mo | ||
// [flattening/modelica/scodeinst/ForStatementAssign1.mo:11:5-11:11:writable] Error: Assignment to iterator 'i'. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// name: ReinitInvalid8 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
|
||
model ReinitInvalid8 | ||
Real x; | ||
equation | ||
for i in 1.0:2.0 loop | ||
when time > 0 then | ||
reinit(i, 1.0); | ||
end when; | ||
end for; | ||
end ReinitInvalid8; | ||
|
||
// Result: | ||
// Error processing file: ReinitInvalid8.mo | ||
// [flattening/modelica/scodeinst/ReinitInvalid8.mo:12:7-12:21:writable] Error: Assignment to iterator 'i'. | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// endResult |