aboutsummaryrefslogtreecommitdiffstats
path: root/docs/contracts.rst
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-07-11 06:07:27 +0800
committerchriseth <chris@ethereum.org>2017-07-14 03:47:29 +0800
commit41e5b2c3c2a84f395da03bfd4cf5bf8586f9df3f (patch)
tree8b8e9eb1136a3705c2e6b9bff04ba1243832db31 /docs/contracts.rst
parentb2fcd59ee6941de4a392b89295c734385d6019e3 (diff)
downloaddexon-solidity-41e5b2c3c2a84f395da03bfd4cf5bf8586f9df3f.tar.gz
dexon-solidity-41e5b2c3c2a84f395da03bfd4cf5bf8586f9df3f.tar.zst
dexon-solidity-41e5b2c3c2a84f395da03bfd4cf5bf8586f9df3f.zip
Fix bugs in example contracts
Diffstat (limited to 'docs/contracts.rst')
-rw-r--r--docs/contracts.rst31
1 files changed, 26 insertions, 5 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst
index e9ea1b3b..3c9769ff 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -213,6 +213,8 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value
::
+ // This will not compile
+
pragma solidity ^0.4.0;
contract C {
@@ -545,9 +547,11 @@ Please ensure you test your fallback function thoroughly to ensure the execution
test.call(0xabcdef01); // hash does not exist
// results in test.x becoming == 1.
- // The following call will fail, reject the
- // Ether and return false:
- test.send(2 ether);
+ // The following will not compile, but even
+ // if someone sends ether to that contract,
+ // the transaction will fail and reject the
+ // Ether.
+ //test.send(2 ether);
}
}
@@ -773,13 +777,17 @@ seen in the following example::
pragma solidity ^0.4.0;
+ contract owned {
+ function owned() { owner = msg.sender; }
+ address owner;
+ }
+
contract mortal is owned {
function kill() {
if (msg.sender == owner) selfdestruct(owner);
}
}
-
contract Base1 is mortal {
function kill() { /* do cleanup 1 */ mortal.kill(); }
}
@@ -800,6 +808,11 @@ derived override, but this function will bypass
pragma solidity ^0.4.0;
+ contract owned {
+ function owned() { owner = msg.sender; }
+ address owner;
+ }
+
contract mortal is owned {
function kill() {
if (msg.sender == owner) selfdestruct(owner);
@@ -879,6 +892,8 @@ error "Linearization of inheritance graph impossible".
::
+ // This will not compile
+
pragma solidity ^0.4.0;
contract X {}
@@ -914,10 +929,16 @@ Contract functions can lack an implementation as in the following example (note
function utterance() returns (bytes32);
}
-Such contracts cannot be compiled (even if they contain implemented functions alongside non-implemented functions), but they can be used as base contracts::
+Such contracts cannot be compiled (even if they contain
+implemented functions alongside non-implemented functions),
+but they can be used as base contracts::
pragma solidity ^0.4.0;
+ contract Feline {
+ function utterance() returns (bytes32);
+ }
+
contract Cat is Feline {
function utterance() returns (bytes32) { return "miaow"; }
}