﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5836	The NF accepts illegal discrete variables	Francesco Casella	Karim Adbdelhak	"Consider this test model
{{{
model M
  discrete Real x;
equation
  if time < 0.5 then
    x = 1;
  else
    x = 0;
  end if;
end M;
}}}

OMC accepts this model. However, the Modelica Specification [https://specification.modelica.org/v3.4/Ch4.html#component-variability-prefixes-discrete-parameter-constant Section 4.4.4] states:

  If a Real variable is declared with the prefix discrete it must in a simulation model be assigned in a when-clause, either by an assignment or an equation.

So I guess it's pretty clear that model {{{M}}} is not valid. I'm not sure whether this kind of issues should be detected by the NF already, or rather by the backend. 

According to the above-mentioned rule, discrete-time Real variables are only expected to be found in the left-hand side of an equation or assigment in a when statement. I guess the frontend can already figure this out, without the need of any sophisticated structural analysis. But maybe it's best to leave this to the backend, I'm not sure. "	defect	closed	blocker	1.16.0	New Instantiation		fixed		Andreas Heuermann Per Östlund
