Opened 6 years ago

Last modified 6 years ago

#5365 new enhancement

find declared but unused variables and parameters

Reported by: Anton Neem Owned by: somebody
Priority: high Milestone: Future
Component: *unknown* Version:
Keywords: Cc:

Description

I sometimes have parameters and/or variables declared, but they are not used anymore due to rewriting the equations (or after some intermediate debugging). Tools like PyCharm (an IDE for Python) can detect such unused variables and warn about them. Would that also be possible with OpenModelica?

Change History (3)

comment:1 by Francesco Casella, 6 years ago

"They are not used anymore due to rewriting the equations" is a bit fuzzy. Could you make one or two simple examples to clarify?

comment:2 by anonymous, 6 years ago

May be he meant something like this

parameter Real a
parameter Real x;
Real b,c;

//b = a*2 "old code";
b = x*2;
//c = a*3; --> if you comment this out, you got 2 variables and one equation

as far as i know, modelica ingored parameter that is not used, but variable that is not used shoud result in number of equations not equal number of variables and you will be warned (i.e. your simulation wont run)

so there is one

in reply to:  2 comment:3 by Francesco Casella, 6 years ago

Replying to anonymous:
If you try to run the following model

model M
  parameter Real a;
  parameter Real x;
  Real b,c;
equation
  //b = a*2 "old code";
  b = x*2;
  //c = a*3; --> if you comment this out, you got 2 variables and one equation
end M;

you get

[1] 15:59:04 Symbolic Error
Too few equations, under-determined system. The model has 1 equation(s) and 2 variable(s).

[2] 15:59:04 Symbolic Warning
[M: 4:1-4:9]: Variable c does not have any remaining equation to be solved in.

Isn't this good enough diagnostics?

Note: See TracTickets for help on using tickets.