Next: , Previous: , Up: Well-formedness – Mixing   [Contents][Index]


11.6.5 Cannot use illegal with imperative statements

An illegal statement must occur on its own; no other actions or assigns are allowed. That also applies if the illegal occurs in a nested compound:

interface imperative_illegal
{
  in void hello ();
  behavior
  {
    bool b = false;
    on hello:
    {
      b = true;
      illegal;
    }
  }
}

This results in the following error message:

imperative-illegal.dzn:10:7: error: cannot use illegal with imperative
    statements
imperative-illegal.dzn:9:7: info: imperative statement here

In a component, using an illegal within a conditional statement is allowed. Also the condition may be accompanied by other actions, e.g:

interface ihello
{
  in void hello();
  behavior
  {
    on hello: {}
  }
}

component component_if_illegal
{
  provides ihello p;
  behavior
  {
    bool b = true;
    on p.hello():
    {
      b = false;
      if (b)
        illegal;
    }
  }
}