From b2fcd59ee6941de4a392b89295c734385d6019e3 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 10 Jul 2017 22:58:23 +0100 Subject: [PATCH] Add version pragma to docs examples --- docs/abi-spec.rst | 2 ++ docs/assembly.rst | 2 ++ docs/control-structures.rst | 10 ++++++++++ docs/miscellaneous.rst | 2 ++ 4 files changed, 16 insertions(+) diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index d915973df..82c521599 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -182,6 +182,8 @@ Given the contract: :: + pragma solidity ^0.4.0; + contract Foo { function bar(bytes3[2] xy) {} function baz(uint32 x, bool y) returns (bool r) { r = x > 32 || y; } diff --git a/docs/assembly.rst b/docs/assembly.rst index 0a1206441..37222fafc 100644 --- a/docs/assembly.rst +++ b/docs/assembly.rst @@ -679,6 +679,8 @@ Example: We will follow an example compilation from Solidity to desugared assembly. We consider the runtime bytecode of the following Solidity program:: + pragma solidity ^0.4.0; + contract C { function f(uint x) returns (uint y) { y = 1; diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 03787c207..c7185e223 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -20,6 +20,8 @@ For example, suppose we want our contract to accept one kind of external calls with two integers, we would write something like:: + pragma solidity ^0.4.0; + contract Simple { function taker(uint _a, uint _b) { // do something with _a and _b. @@ -34,6 +36,8 @@ The output parameters can be declared with the same syntax after the the sum and the product of the two given integers, then we would write:: + pragma solidity ^0.4.0; + contract Simple { function arithmetics(uint _a, uint _b) returns (uint o_sum, uint o_product) { o_sum = _a + _b; @@ -91,6 +95,8 @@ Internal Function Calls Functions of the current contract can be called directly ("internally"), also recursively, as seen in this nonsensical example:: + pragma solidity ^0.4.0; + contract C { function g(uint a) returns (uint ret) { return f(); } function f() returns (uint ret) { return g(7) + f(); } @@ -116,6 +122,8 @@ all function arguments have to be copied to memory. When calling functions of other contracts, the amount of Wei sent with the call and the gas can be specified with special options ``.value()`` and ``.gas()``, respectively:: + pragma solidity ^0.4.0; + contract InfoFeed { function info() payable returns (uint ret) { return 42; } } @@ -261,6 +269,8 @@ Destructuring Assignments and Returning Multiple Values Solidity internally allows tuple types, i.e. a list of objects of potentially different types whose size is a constant at compile-time. Those tuples can be used to return multiple values at the same time and also assign them to multiple variables (or LValues in general) at the same time:: + pragma solidity ^0.4.0; + contract C { uint[] data; diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index 182de33ad..1fcdb2fce 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -48,6 +48,8 @@ non-elementary type, the positions are found by adding an offset of ``keccak256( So for the following contract snippet:: + pragma solidity ^0.4.0; + contract C { struct s { uint a; uint b; } uint x;