Navigation
Synopsis Use of fail statement outside a condtional context.
Description A Rascal:Fail statement is only allowed inside conditional statements. This error is generated when fail is used outside a conditional context.

Remedies:
  • Surround the fail statement by a conditional conditional statement.
  • Replace the fail statement by a Rascal:Throw statement.
  • replace the fail statement by a Rascal:Return statement.
Examples Here is a correct (albeit not very useful) use of fail where the pattern match int N := 35 acts as guard:
rascal>if(int N := 35){ if(N > 10) fail; }
ok
Any condition (non only one using pattern matching) can act as guard:
rascal>if(true) { fail; }
ok
An error occurs when fail is used outside a conditional context:
rascal>fail;
|stdin:///|(0,5,<1,0>,<1,5>): Use of fail outside a conditional context
rascal>
cancelled
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.