﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
2105	State machine example incorrectly produces overdetermined system	jwharington@…	probably noone	"Two equivalent codes, simulating the startup sequence of a state machine.

This first code does not compile (overdetermined system):
{{{
class stateinit

  class StateMachine
    Boolean active;
    Boolean init;
  algorithm

    when init then
      init := false;
      // do something, next state
    end when;

  end StateMachine;

  StateMachine statemachine;

algorithm
  when time > 0.1 then
    // activate state machine, initial state
    statemachine.init := true;
    statemachine.active := true;
  end when;

end stateinit;
}}}

But this code does compile fine:
{{{

class stateinit2

  class StateMachine
    Boolean active;
    Boolean init;
  algorithm

    when active then
      init := true;
      // activate initial state
    end when;

    when init then
      init := false;
      // do something, next state
    end when;

  end StateMachine;

  StateMachine statemachine;

algorithm
  when time > 0.1 then
    // activate state machine
    statemachine.active := true;
  end when;

end stateinit2;
}}}

Now, here's a weird thing.  When I take the flattened code of the first example (stateinit), replace '.' with '_' and compile it, it compiles and works fine.
{{{
class stateinit3
  Boolean statemachine_active;
  Boolean statemachine_init;
algorithm
  when statemachine_init then
    statemachine_init := false;
  end when;
  when time > 0.1 then
    statemachine_init := true;
    statemachine_active := true;
  end when;
end stateinit3;
}}}

How is it the first example fails, yet the same flattened code compiles fine on its own?
"	defect	closed	high	1.13.0	Backend	trunk	wontfix		Jens Frenkel Willi Braun Lennart Ochel
