﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3220	Bug with for loop in algorithms	Adrian Pop	somebody	"Reported here:
https://openmodelica.org/forum/default-topic/1557-for-loop-bug

{{{#!mo
model ForLoopBug 
  parameter Integer N = 1; 
  parameter Real p_in = 2e5; 
  Real[N + 1] p; 
  Real[N] dp; 
algorithm
  p[1] := p_in; 
  for i in 1:N loop 
    dp[i] := 10; 
    p[i + 1] := p[i] - dp[i]; 
  end for; 
end ForLoopBug;
}}}

Trying to simulate it gets you:
{{{
""Error: Model is structurally singular, error found sorting equations 
 1: algorithm
  p[1] := p_in;
  for i in 1:1 loop
    dp[i] := 10.0;
    p[1 + i] := p[i] - dp[i];
  end for;
;
 for variables 
 p[2](2), p[1](3), dp[1](1)
Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed!
""
}}}"	defect	closed	high	1.19.0	Backend	trunk	fixed		Gustaf Thorslund
