﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5531	Implicit cast from Real to Integer	Andreas Heuermann	Andreas Heuermann	"Is the following model legal Modelica syntax?
{{{
model TestInt
  Real x(start=1);
  Integer y;
equation 
   der(x) = x;
   y = x;
end TestInt;
}}}
A real is casted to an integer and no warning or error is printed by OMC. In my opinion it is not 100% defined what should happen an the user should explicit state what he wants, e.g. use `ceil(x)`, `floor(x)` or `integer(x)`.

Dymola will report:
{{{
Translation of TestInt:

The problem is structurally singular.

It has 2 scalar unknowns and 2 scalar equations.
The Real part has 1 unknowns and 2 equations.
The Integer part has 1 unknowns and 0 equations.
The Boolean part has 0 unknowns and 0 equations.
The String part has 0 unknowns and 0 equations.

Attempting to further localize singularity.

Singularity of TestInt is at the top level.

The model TestInt is structurally singular.

The problem is structurally singular for the element type Real.

The number of scalar Real unknown elements are 1.
The number of scalar Real equation elements are 2.

Part of the problem for Real elements is overdetermined.
There are 1 scalar equations too many in the set:
y = x;
der(x) = x;
which was derived from
der(x) = x;

The problem is structurally singular for the element type Integer.

The number of scalar Integer unknown elements are 1.
The number of scalar Integer equation elements are 0.

The following variables are considered as unknowns, but are not appearing in the equations.
y

Translation aborted.

WARNINGS have been issued.

ERRORS have been issued.
}}}

My suggestion: Throw an error (while parsing or from the Frontend) and only accept a correct version like:
{{{
model TestInt
  Real x(start=1);
  Integer y;
equation 
   der(x) = x;
   y = integer(x);
end TestInt;
}}}
Or give a warning and implicit cast all non-real variables to integers like above.

For the example above it's pretty clear what should happen. But what is the correct solution for the following model?
{{{
model TestInt2
  Real x(start=1);
  Real y;
  Integer z;
equation 
   der(x) = x;
   z = x;
   der(y) = z;
end TestInt2;
}}}
`der(y)` should now be discrete (equals 1 up to time=0.69 and after that equals 2) but it's computed solution is in fact equal to `der(x)`. Whit a warning or error a user would notice that this model doesn't make much sense."	defect	assigned	critical	2.0.0	Backend	v1.14.0-dev-nightly			
