Skip to content

Commit

Permalink
exit() statement
Browse files Browse the repository at this point in the history
  • Loading branch information
xhliu committed Feb 11, 2020
1 parent 7e845dc commit 468040f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Formal Specification
stmt &::= \mathrm{TYPE}\ \mathrm{ID} = expr;\\
&\ \ \ |\ \ \mathrm{ID} = expr;\\
&\ \ \ |\ \ \mathrm{require}(expr);\\
&\ \ \ |\ \ \mathrm{exit}(expr);\\
&\ \ \ |\ \ \mathrm{if}\ (expr)\ stmt\ [\mathrm{else}\ stmt]\\
&\ \ \ |\ \ \mathrm{loop}\ (intConst)\ stmt\\
&\ \ \ |\ \ \{\ [stmt]^*\ \}\\
Expand Down Expand Up @@ -111,6 +112,28 @@ To cast a supertype ``bytes`` to them, a function of the type name must be expli
Sha256 s = hash256(b"00112233445566778899aabbccddeeffffeeddccbbaa99887766554433221100");
``exit()``
==========
``exit(bool status);`` statement terminates contract execution. If ``status`` is ``true``, contract succeeds; otherwise, it fails.

.. code-block:: solidity
contract TestPositive {
int x;
constructor(int x) {
this.x = x;
}
public function equal(int y) {
if (y <= 0) {
exit(false);
}
require(y == this.x);
}
}
Operators
=========

Expand Down

0 comments on commit 468040f

Please sign in to comment.