aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-09-05 23:11:53 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-09-14 23:29:39 +0800
commitdf8380193b3263b20f462b5d17a43a642b7f9585 (patch)
treec84189c6e74ad86590eb23ca0393c87afd49e8b0 /test/libsolidity
parenta02cf83d86489f5d9c9439c79e27fcecb5c5ddb4 (diff)
downloaddexon-solidity-df8380193b3263b20f462b5d17a43a642b7f9585.tar.gz
dexon-solidity-df8380193b3263b20f462b5d17a43a642b7f9585.tar.zst
dexon-solidity-df8380193b3263b20f462b5d17a43a642b7f9585.zip
Update type tests to contain mandatory visibility specifiers
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp1001
1 files changed, 506 insertions, 495 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index c7ef1d46..8c271fe1 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
char const* text = R"(
contract test {
uint256 stateVariable1;
- function fun(uint256 arg1) { uint256 y; y = arg1; }
+ function fun(uint256 arg1) public { uint256 y; y = arg1; }
}
)";
CHECK_SUCCESS(text);
@@ -67,8 +67,8 @@ BOOST_AUTO_TEST_CASE(double_function_declaration)
{
char const* text = R"(
contract test {
- function fun() { }
- function fun() { }
+ function fun() public { }
+ function fun() public { }
}
)";
CHECK_ERROR(text, DeclarationError, "Function with same name and arguments defined twice.");
@@ -78,9 +78,9 @@ BOOST_AUTO_TEST_CASE(double_variable_declaration)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
uint256 x;
- if (true) { uint256 x; }
+ if (true) { uint256 x; }
}
}
)";
@@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(name_shadowing)
char const* text = R"(
contract test {
uint256 variable;
- function f() { uint32 variable; variable = 2; }
+ function f() public { uint32 variable; variable = 2; }
}
)";
CHECK_SUCCESS(text);
@@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(name_references)
char const* text = R"(
contract test {
uint256 variable;
- function f(uint256) returns (uint out) { f(variable); test; out; }
+ function f(uint256) public returns (uint out) { f(variable); test; out; }
}
)";
CHECK_SUCCESS(text);
@@ -114,7 +114,7 @@ BOOST_AUTO_TEST_CASE(undeclared_name)
char const* text = R"(
contract test {
uint256 variable;
- function f(uint256 arg) {
+ function f(uint256 arg) public {
f(notfound);
}
}
@@ -126,8 +126,8 @@ BOOST_AUTO_TEST_CASE(reference_to_later_declaration)
{
char const* text = R"(
contract test {
- function g() { f(); }
- function f() {}
+ function g() public { f(); }
+ function f() public {}
}
)";
CHECK_SUCCESS(text);
@@ -192,7 +192,7 @@ BOOST_AUTO_TEST_CASE(type_inference_smoke_test)
{
char const* text = R"(
contract test {
- function f(uint256 arg1, uint32 arg2) returns (bool ret) {
+ function f(uint256 arg1, uint32 arg2) public returns (bool ret) {
var x = arg1 + arg2 == 8; ret = x;
}
}
@@ -204,7 +204,7 @@ BOOST_AUTO_TEST_CASE(type_checking_return)
{
char const* text = R"(
contract test {
- function f() returns (bool r) { return 1 >= 2; }
+ function f() public returns (bool r) { return 1 >= 2; }
}
)";
CHECK_SUCCESS(text);
@@ -214,7 +214,7 @@ BOOST_AUTO_TEST_CASE(type_checking_return_wrong_number)
{
char const* text = R"(
contract test {
- function f() returns (bool r1, bool r2) { return 1 >= 2; }
+ function f() public returns (bool r1, bool r2) { return 1 >= 2; }
}
)";
CHECK_ERROR(text, TypeError, "Different number of arguments in return statement than in returns declaration.");
@@ -224,7 +224,7 @@ BOOST_AUTO_TEST_CASE(type_checking_return_wrong_type)
{
char const* text = R"(
contract test {
- function f() returns (uint256 r) { return 1 >= 2; }
+ function f() public returns (uint256 r) { return 1 >= 2; }
}
)";
CHECK_ERROR(text, TypeError, "Return argument type bool is not implicitly convertible to expected type (type of first return variable) uint256.");
@@ -234,8 +234,8 @@ BOOST_AUTO_TEST_CASE(type_checking_function_call)
{
char const* text = R"(
contract test {
- function f() returns (bool) { return g(12, true) == 3; }
- function g(uint256, bool) returns (uint256) { }
+ function f() public returns (bool) { return g(12, true) == 3; }
+ function g(uint256, bool) public returns (uint256) { }
}
)";
CHECK_SUCCESS(text);
@@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE(type_conversion_for_comparison)
{
char const* text = R"(
contract test {
- function f() { uint32(2) == int64(2); }
+ function f() public { uint32(2) == int64(2); }
}
)";
CHECK_SUCCESS(text);
@@ -255,7 +255,7 @@ BOOST_AUTO_TEST_CASE(type_conversion_for_comparison_invalid)
{
char const* text = R"(
contract test {
- function f() { int32(2) == uint64(2); }
+ function f() public { int32(2) == uint64(2); }
}
)";
CHECK_ERROR(text, TypeError, "Operator == not compatible with types int32 and uint64");
@@ -265,7 +265,7 @@ BOOST_AUTO_TEST_CASE(type_inference_explicit_conversion)
{
char const* text = R"(
contract test {
- function f() returns (int256 r) { var x = int256(uint32(2)); return x; }
+ function f() public returns (int256 r) { var x = int256(uint32(2)); return x; }
}
)";
CHECK_SUCCESS(text);
@@ -275,7 +275,7 @@ BOOST_AUTO_TEST_CASE(large_string_literal)
{
char const* text = R"(
contract test {
- function f() { var x = "123456789012345678901234567890123"; }
+ function f() public { var x = "123456789012345678901234567890123"; }
}
)";
CHECK_SUCCESS(text);
@@ -285,7 +285,7 @@ BOOST_AUTO_TEST_CASE(balance)
{
char const* text = R"(
contract test {
- function fun() {
+ function fun() public {
uint256 x = address(0).balance;
}
}
@@ -297,7 +297,7 @@ BOOST_AUTO_TEST_CASE(balance_invalid)
{
char const* text = R"(
contract test {
- function fun() {
+ function fun() public {
address(0).balance = 7;
}
}
@@ -313,7 +313,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_mapping)
mapping(uint=>uint) map;
}
str data;
- function fun() {
+ function fun() public {
var a = data.map;
data.map = a;
}
@@ -330,7 +330,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_struct)
mapping(uint=>uint) map;
}
str data;
- function fun() {
+ function fun() public {
var a = data;
data = a;
}
@@ -343,7 +343,7 @@ BOOST_AUTO_TEST_CASE(returns_in_constructor)
{
char const* text = R"(
contract test {
- function test() returns (uint a) { }
+ function test() public returns (uint a) { }
}
)";
CHECK_ERROR(text, TypeError, "Non-empty \"returns\" directive for constructor.");
@@ -353,12 +353,12 @@ BOOST_AUTO_TEST_CASE(forward_function_reference)
{
char const* text = R"(
contract First {
- function fun() returns (bool) {
+ function fun() public returns (bool) {
return Second(1).fun(1, true, 3) > 0;
}
}
contract Second {
- function fun(uint, bool, uint) returns (uint) {
+ function fun(uint, bool, uint) public returns (uint) {
if (First(2).fun() == true) return 1;
}
}
@@ -370,7 +370,7 @@ BOOST_AUTO_TEST_CASE(comparison_bitop_precedence)
{
char const* text = R"(
contract First {
- function fun() returns (bool ret) {
+ function fun() public returns (bool ret) {
return 1 & 2 == 8 & 9 && 1 ^ 2 < 4 | 6;
}
}
@@ -382,7 +382,7 @@ BOOST_AUTO_TEST_CASE(comparison_of_function_types)
{
char const* text = R"(
contract C {
- function f() returns (bool ret) {
+ function f() public returns (bool ret) {
return this.f < this.f;
}
}
@@ -390,7 +390,7 @@ BOOST_AUTO_TEST_CASE(comparison_of_function_types)
CHECK_ERROR(text, TypeError, "Operator < not compatible");
text = R"(
contract C {
- function f() returns (bool ret) {
+ function f() public returns (bool ret) {
return f < f;
}
}
@@ -398,10 +398,10 @@ BOOST_AUTO_TEST_CASE(comparison_of_function_types)
CHECK_ERROR(text, TypeError, "Operator < not compatible");
text = R"(
contract C {
- function f() returns (bool ret) {
+ function f() public returns (bool ret) {
return f == f;
}
- function g() returns (bool ret) {
+ function g() public returns (bool ret) {
return f != f;
}
}
@@ -414,7 +414,7 @@ BOOST_AUTO_TEST_CASE(comparison_of_mapping_types)
char const* text = R"(
contract C {
mapping(uint => uint) x;
- function f() returns (bool ret) {
+ function f() public returns (bool ret) {
var y = x;
return x == y;
}
@@ -428,7 +428,7 @@ BOOST_AUTO_TEST_CASE(function_no_implementation)
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
contract test {
- function functionName(bytes32 input) returns (bytes32 out);
+ function functionName(bytes32 input) public returns (bytes32 out);
}
)";
sourceUnit = parseAndAnalyse(text);
@@ -444,7 +444,7 @@ BOOST_AUTO_TEST_CASE(abstract_contract)
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
contract base { function foo(); }
- contract derived is base { function foo() {} }
+ contract derived is base { function foo() public {} }
)";
sourceUnit = parseAndAnalyse(text);
std::vector<ASTPointer<ASTNode>> nodes = sourceUnit->nodes();
@@ -463,7 +463,7 @@ BOOST_AUTO_TEST_CASE(abstract_contract_with_overload)
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
contract base { function foo(bool); }
- contract derived is base { function foo(uint) {} }
+ contract derived is base { function foo(uint) public {} }
)";
sourceUnit = parseAndAnalyse(text);
std::vector<ASTPointer<ASTNode>> nodes = sourceUnit->nodes();
@@ -481,7 +481,7 @@ BOOST_AUTO_TEST_CASE(create_abstract_contract)
contract base { function foo(); }
contract derived {
base b;
- function foo() { b = new base(); }
+ function foo() public { b = new base(); }
}
)";
CHECK_ERROR(text, TypeError, "Trying to create an instance of an abstract contract.");
@@ -491,7 +491,7 @@ BOOST_AUTO_TEST_CASE(redeclare_implemented_abstract_function_as_abstract)
{
char const* text = R"(
contract base { function foo(); }
- contract derived is base { function foo() {} }
+ contract derived is base { function foo() public {} }
contract wrong is derived { function foo(); }
)";
CHECK_ERROR(text, TypeError, "Redeclaring an already implemented function as abstract");
@@ -502,7 +502,7 @@ BOOST_AUTO_TEST_CASE(implement_abstract_via_constructor)
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
contract base { function foo(); }
- contract foo is base { function foo() {} }
+ contract foo is base { function foo() public {} }
)";
sourceUnit = parseAndAnalyse(text);
std::vector<ASTPointer<ASTNode>> nodes = sourceUnit->nodes();
@@ -517,7 +517,7 @@ BOOST_AUTO_TEST_CASE(function_canonical_signature)
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
contract Test {
- function foo(uint256 arg1, uint64 arg2, bool arg3) returns (uint256 ret) {
+ function foo(uint256 arg1, uint64 arg2, bool arg3) public returns (uint256 ret) {
ret = arg1 + arg2;
}
}
@@ -536,7 +536,7 @@ BOOST_AUTO_TEST_CASE(function_canonical_signature_type_aliases)
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
contract Test {
- function boo(uint, bytes32, address) returns (uint ret) {
+ function boo(uint, bytes32, address) public returns (uint ret) {
ret = 5;
}
}
@@ -604,7 +604,7 @@ BOOST_AUTO_TEST_CASE(function_external_call_allowed_conversion)
char const* text = R"(
contract C {}
contract Test {
- function externalCall() {
+ function externalCall() public {
C arg;
this.g(arg);
}
@@ -619,7 +619,7 @@ BOOST_AUTO_TEST_CASE(function_external_call_not_allowed_conversion)
char const* text = R"(
contract C {}
contract Test {
- function externalCall() {
+ function externalCall() public {
address arg;
this.g(arg);
}
@@ -637,8 +637,8 @@ BOOST_AUTO_TEST_CASE(function_internal_allowed_conversion)
}
contract Test {
C a;
- function g (C c) {}
- function internalCall() {
+ function g (C c) public {}
+ function internalCall() public {
g(a);
}
}
@@ -654,8 +654,8 @@ BOOST_AUTO_TEST_CASE(function_internal_not_allowed_conversion)
}
contract Test {
address a;
- function g (C c) {}
- function internalCall() {
+ function g (C c) public {}
+ function internalCall() public {
g(a);
}
}
@@ -667,8 +667,8 @@ BOOST_AUTO_TEST_CASE(hash_collision_in_interface)
{
char const* text = R"(
contract test {
- function gsf() { }
- function tgeo() { }
+ function gsf() public { }
+ function tgeo() public { }
}
)";
CHECK_ERROR(text, TypeError, "Function signature hash collision for tgeo()");
@@ -680,7 +680,7 @@ BOOST_AUTO_TEST_CASE(inheritance_basic)
contract base { uint baseMember; struct BaseType { uint element; } }
contract derived is base {
BaseType data;
- function f() { baseMember = 7; }
+ function f() public { baseMember = 7; }
}
)";
CHECK_SUCCESS(text);
@@ -689,11 +689,11 @@ BOOST_AUTO_TEST_CASE(inheritance_basic)
BOOST_AUTO_TEST_CASE(inheritance_diamond_basic)
{
char const* text = R"(
- contract root { function rootFunction() {} }
- contract inter1 is root { function f() {} }
- contract inter2 is root { function f() {} }
+ contract root { function rootFunction() public {} }
+ contract inter1 is root { function f() public {} }
+ contract inter2 is root { function f() public {} }
contract derived is root, inter2, inter1 {
- function g() { f(); rootFunction(); }
+ function g() public { f(); rootFunction(); }
}
)";
CHECK_SUCCESS(text);
@@ -711,8 +711,8 @@ BOOST_AUTO_TEST_CASE(cyclic_inheritance)
BOOST_AUTO_TEST_CASE(legal_override_direct)
{
char const* text = R"(
- contract B { function f() {} }
- contract C is B { function f(uint i) {} }
+ contract B { function f() public {} }
+ contract C is B { function f(uint i) public {} }
)";
CHECK_SUCCESS(text);
}
@@ -720,8 +720,8 @@ BOOST_AUTO_TEST_CASE(legal_override_direct)
BOOST_AUTO_TEST_CASE(legal_override_indirect)
{
char const* text = R"(
- contract A { function f(uint a) {} }
- contract B { function f() {} }
+ contract A { function f(uint a) public {} }
+ contract B { function f() public {} }
contract C is A, B { }
)";
CHECK_SUCCESS(text);
@@ -740,7 +740,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_remove_constness)
{
char const* text = R"(
contract B { function f() constant {} }
- contract C is B { function f() {} }
+ contract C is B { function f() public {} }
)";
CHECK_ERROR(text, TypeError, "Overriding function changes state mutability from \"view\" to \"nonpayable\".");
}
@@ -748,7 +748,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_remove_constness)
BOOST_AUTO_TEST_CASE(illegal_override_add_constness)
{
char const* text = R"(
- contract B { function f() {} }
+ contract B { function f() public {} }
contract C is B { function f() constant {} }
)";
CHECK_ERROR(text, TypeError, "Overriding function changes state mutability from \"nonpayable\" to \"view\".");
@@ -757,8 +757,8 @@ BOOST_AUTO_TEST_CASE(illegal_override_add_constness)
BOOST_AUTO_TEST_CASE(complex_inheritance)
{
char const* text = R"(
- contract A { function f() { uint8 x = C(0).g(); } }
- contract B { function f() {} function g() returns (uint8) {} }
+ contract A { function f() public { uint8 x = C(0).g(); } }
+ contract B { function f() public {} function g() public returns (uint8) {} }
contract C is A, B { }
)";
CHECK_SUCCESS(text);
@@ -768,8 +768,8 @@ BOOST_AUTO_TEST_CASE(constructor_visibility)
{
// The constructor of a base class should not be visible in the derived class
char const* text = R"(
- contract A { function A() { } }
- contract B is A { function f() { A x = A(0); } }
+ contract A { function A() public { } }
+ contract B is A { function f() public { A x = A(0); } }
)";
CHECK_SUCCESS(text);
}
@@ -778,8 +778,8 @@ BOOST_AUTO_TEST_CASE(overriding_constructor)
{
// It is fine to "override" constructor of a base class since it is invisible
char const* text = R"(
- contract A { function A() { } }
- contract B is A { function A() returns (uint8 r) {} }
+ contract A { function A() public { } }
+ contract B is A { function A() public returns (uint8 r) {} }
)";
CHECK_SUCCESS(text);
}
@@ -787,7 +787,7 @@ BOOST_AUTO_TEST_CASE(overriding_constructor)
BOOST_AUTO_TEST_CASE(missing_base_constructor_arguments)
{
char const* text = R"(
- contract A { function A(uint a) { } }
+ contract A { function A(uint a) public { } }
contract B is A { }
)";
CHECK_SUCCESS(text);
@@ -796,7 +796,7 @@ BOOST_AUTO_TEST_CASE(missing_base_constructor_arguments)
BOOST_AUTO_TEST_CASE(base_constructor_arguments_override)
{
char const* text = R"(
- contract A { function A(uint a) { } }
+ contract A { function A(uint a) public { } }
contract B is A { }
)";
CHECK_SUCCESS(text);
@@ -807,7 +807,7 @@ BOOST_AUTO_TEST_CASE(implicit_derived_to_base_conversion)
char const* text = R"(
contract A { }
contract B is A {
- function f() { A a = B(1); }
+ function f() public { A a = B(1); }
}
)";
CHECK_SUCCESS(text);
@@ -818,7 +818,7 @@ BOOST_AUTO_TEST_CASE(implicit_base_to_derived_conversion)
char const* text = R"(
contract A { }
contract B is A {
- function f() { B b = A(1); }
+ function f() public { B b = A(1); }
}
)";
CHECK_ERROR(text, TypeError, "Type contract A is not implicitly convertible to expected type contract B.");
@@ -828,11 +828,11 @@ BOOST_AUTO_TEST_CASE(super_excludes_current_contract)
{
char const* text = R"(
contract A {
- function b() {}
+ function b() public {}
}
contract B is A {
- function f() {
+ function f() public {
super.f();
}
}
@@ -845,7 +845,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation)
{
char const* text = R"(
contract B {
- function f() mod1(2, true) mod2("0123456") { }
+ function f() mod1(2, true) mod2("0123456") public { }
modifier mod1(uint a, bool b) { if (b) _; }
modifier mod2(bytes7 a) { while (a == "1234567") _; }
}
@@ -857,7 +857,7 @@ BOOST_AUTO_TEST_CASE(invalid_function_modifier_type)
{
char const* text = R"(
contract B {
- function f() mod1(true) { }
+ function f() mod1(true) public { }
modifier mod1(uint a) { if (a > 0) _; }
}
)";
@@ -868,7 +868,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation_parameters)
{
char const* text = R"(
contract B {
- function f(uint8 a) mod1(a, true) mod2(r) returns (bytes7 r) { }
+ function f(uint8 a) mod1(a, true) mod2(r) public returns (bytes7 r) { }
modifier mod1(uint a, bool b) { if (b) _; }
modifier mod2(bytes7 a) { while (a == "1234567") _; }
}
@@ -880,7 +880,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation_local_variables)
{
char const* text = R"(
contract B {
- function f() mod(x) { uint x = 7; }
+ function f() mod(x) public { uint x = 7; }
modifier mod(uint a) { if (a > 0) _; }
}
)";
@@ -891,7 +891,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_double_invocation)
{
char const* text = R"(
contract B {
- function f(uint x) mod(x) mod(2) { }
+ function f(uint x) mod(x) mod(2) public { }
modifier mod(uint a) { if (a > 0) _; }
}
)";
@@ -901,9 +901,9 @@ BOOST_AUTO_TEST_CASE(function_modifier_double_invocation)
BOOST_AUTO_TEST_CASE(base_constructor_double_invocation)
{
char const* text = R"(
- contract C { function C(uint a) {} }
+ contract C { function C(uint a) public {} }
contract B is C {
- function B() C(2) C(2) {}
+ function B() C(2) C(2) public {}
}
)";
CHECK_ERROR(text, DeclarationError, "Base constructor already provided");
@@ -931,7 +931,7 @@ BOOST_AUTO_TEST_CASE(modifier_overrides_function)
{
char const* text = R"(
contract A { modifier mod(uint a) { _; } }
- contract B is A { function mod(uint a) { } }
+ contract B is A { function mod(uint a) public { } }
)";
// Error: Identifier already declared.
// Error: Override changes modifier to function.
@@ -941,7 +941,7 @@ BOOST_AUTO_TEST_CASE(modifier_overrides_function)
BOOST_AUTO_TEST_CASE(function_overrides_modifier)
{
char const* text = R"(
- contract A { function mod(uint a) { } }
+ contract A { function mod(uint a) public { } }
contract B is A { modifier mod(uint a) { _; } }
)";
// Error: Identifier already declared.
@@ -953,7 +953,7 @@ BOOST_AUTO_TEST_CASE(modifier_returns_value)
{
char const* text = R"(
contract A {
- function f(uint a) mod(2) returns (uint r) { }
+ function f(uint a) mod(2) public returns (uint r) { }
modifier mod(uint a) { _; return 7; }
}
)";
@@ -964,7 +964,7 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors)
{
char const* text = R"(
contract test {
- function fun() {
+ function fun() public {
uint64(2);
}
uint256 public foo;
@@ -1005,11 +1005,11 @@ BOOST_AUTO_TEST_CASE(function_clash_with_state_variable_accessor)
{
char const* text = R"(
contract test {
- function fun() {
+ function fun() public {
uint64(2);
}
uint256 foo;
- function foo() {}
+ function foo() public {}
}
)";
CHECK_ERROR(text, DeclarationError, "Identifier already declared.");
@@ -1019,7 +1019,7 @@ BOOST_AUTO_TEST_CASE(private_state_variable)
{
char const* text = R"(
contract test {
- function fun() {
+ function fun() public {
uint64(2);
}
uint256 private foo;
@@ -1041,7 +1041,7 @@ BOOST_AUTO_TEST_CASE(missing_state_variable)
{
char const* text = R"(
contract Scope {
- function getStateVar() constant returns (uint stateVar) {
+ function getStateVar() constant public returns (uint stateVar) {
stateVar = Scope.stateVar; // should fail.
}
}
@@ -1058,7 +1058,7 @@ BOOST_AUTO_TEST_CASE(base_class_state_variable_accessor)
uint256 public m_aMember;
}
contract Child is Parent {
- function foo() returns (uint256) { return Parent.m_aMember; }
+ function foo() public returns (uint256) { return Parent.m_aMember; }
}
)";
CHECK_SUCCESS(text);
@@ -1081,8 +1081,8 @@ BOOST_AUTO_TEST_CASE(base_class_state_variable_internal_member)
contract Parent {
uint256 internal m_aMember;
}
- contract Child is Parent{
- function foo() returns (uint256) { return Parent.m_aMember; }
+ contract Child is Parent {
+ function foo() public returns (uint256) { return Parent.m_aMember; }
}
)";
CHECK_SUCCESS(text);
@@ -1094,11 +1094,11 @@ BOOST_AUTO_TEST_CASE(state_variable_member_of_wrong_class1)
contract Parent1 {
uint256 internal m_aMember1;
}
- contract Parent2 is Parent1{
+ contract Parent2 is Parent1 {
uint256 internal m_aMember2;
}
- contract Child is Parent2{
- function foo() returns (uint256) { return Parent2.m_aMember1; }
+ contract Child is Parent2 {
+ function foo() public returns (uint256) { return Parent2.m_aMember1; }
}
)";
CHECK_ERROR(text, TypeError, "Member \"m_aMember1\" not found or not visible after argument-dependent lookup in type(contract Parent2)");
@@ -1114,7 +1114,7 @@ BOOST_AUTO_TEST_CASE(state_variable_member_of_wrong_class2)
uint256 internal m_aMember2;
}
contract Child is Parent2 {
- function foo() returns (uint256) { return Child.m_aMember2; }
+ function foo() public returns (uint256) { return Child.m_aMember2; }
uint256 public m_aMember3;
}
)";
@@ -1126,7 +1126,7 @@ BOOST_AUTO_TEST_CASE(fallback_function)
char const* text = R"(
contract C {
uint x;
- function() { x = 2; }
+ function() public { x = 2; }
}
)";
CHECK_SUCCESS(text);
@@ -1137,7 +1137,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_with_arguments)
char const* text = R"(
contract C {
uint x;
- function(uint a) { x = 2; }
+ function(uint a) public { x = 2; }
}
)";
CHECK_ERROR(text, TypeError, "Fallback function cannot take parameters.");
@@ -1147,7 +1147,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_in_library)
{
char const* text = R"(
library C {
- function() {}
+ function() public {}
}
)";
CHECK_ERROR(text, TypeError, "Libraries cannot have fallback functions.");
@@ -1157,7 +1157,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_with_return_parameters)
{
char const* text = R"(
contract C {
- function() returns (uint) { }
+ function() public returns (uint) { }
}
)";
CHECK_ERROR(text, TypeError, "Fallback function cannot return values.");
@@ -1179,8 +1179,8 @@ BOOST_AUTO_TEST_CASE(fallback_function_twice)
char const* text = R"(
contract C {
uint x;
- function() { x = 2; }
- function() { x = 3; }
+ function() public { x = 2; }
+ function() public { x = 3; }
}
)";
CHECK_ERROR_ALLOW_MULTI(text, DeclarationError, "Function with same name and arguments defined twice.");
@@ -1191,10 +1191,10 @@ BOOST_AUTO_TEST_CASE(fallback_function_inheritance)
char const* text = R"(
contract A {
uint x;
- function() { x = 1; }
+ function() public { x = 1; }
}
contract C is A {
- function() { x = 2; }
+ function() public { x = 2; }
}
)";
CHECK_SUCCESS(text);
@@ -1205,7 +1205,7 @@ BOOST_AUTO_TEST_CASE(event)
char const* text = R"(
contract c {
event e(uint indexed a, bytes3 indexed s, bool indexed b);
- function f() { e(2, "abc", true); }
+ function f() public { e(2, "abc", true); }
}
)";
CHECK_SUCCESS(text);
@@ -1257,7 +1257,7 @@ BOOST_AUTO_TEST_CASE(event_call)
char const* text = R"(
contract c {
event e(uint a, bytes3 indexed s, bool indexed b);
- function f() { e(2, "abc", true); }
+ function f() public { e(2, "abc", true); }
}
)";
CHECK_SUCCESS(text);
@@ -1267,7 +1267,7 @@ BOOST_AUTO_TEST_CASE(event_function_inheritance_clash)
{
char const* text = R"(
contract A {
- function dup() returns (uint) {
+ function dup() public returns (uint) {
return 1;
}
}
@@ -1287,7 +1287,7 @@ BOOST_AUTO_TEST_CASE(function_event_inheritance_clash)
event dup();
}
contract A {
- function dup() returns (uint) {
+ function dup() public returns (uint) {
return 1;
}
}
@@ -1302,7 +1302,7 @@ BOOST_AUTO_TEST_CASE(function_event_in_contract_clash)
char const* text = R"(
contract A {
event dup();
- function dup() returns (uint) {
+ function dup() public returns (uint) {
return 1;
}
}
@@ -1317,7 +1317,7 @@ BOOST_AUTO_TEST_CASE(event_inheritance)
event e(uint a, bytes3 indexed s, bool indexed b);
}
contract c is base {
- function f() { e(2, "abc", true); }
+ function f() public { e(2, "abc", true); }
}
)";
CHECK_SUCCESS(text);
@@ -1338,10 +1338,10 @@ BOOST_AUTO_TEST_CASE(access_to_default_function_visibility)
{
char const* text = R"(
contract c {
- function f() {}
+ function f() public {}
}
contract d {
- function g() { c(0).f(); }
+ function g() public { c(0).f(); }
}
)";
CHECK_SUCCESS(text);
@@ -1354,7 +1354,7 @@ BOOST_AUTO_TEST_CASE(access_to_internal_function)
function f() internal {}
}
contract d {
- function g() { c(0).f(); }
+ function g() public { c(0).f(); }
}
)";
CHECK_ERROR(text, TypeError, "Member \"f\" not found or not visible after argument-dependent lookup in contract c");
@@ -1367,7 +1367,7 @@ BOOST_AUTO_TEST_CASE(access_to_default_state_variable_visibility)
uint a;
}
contract d {
- function g() { c(0).a(); }
+ function g() public { c(0).a(); }
}
)";
CHECK_ERROR(text, TypeError, "Member \"a\" not found or not visible after argument-dependent lookup in contract c");
@@ -1380,7 +1380,7 @@ BOOST_AUTO_TEST_CASE(access_to_internal_state_variable)
uint public a;
}
contract d {
- function g() { c(0).a(); }
+ function g() public { c(0).a(); }
}
)";
CHECK_SUCCESS(text);
@@ -1390,10 +1390,10 @@ BOOST_AUTO_TEST_CASE(error_count_in_named_args)
{
char const* sourceCode = R"(
contract test {
- function a(uint a, uint b) returns (uint r) {
+ function a(uint a, uint b) public returns (uint r) {
r = a + b;
}
- function b() returns (uint r) {
+ function b() public returns (uint r) {
r = a({a: 1});
}
}
@@ -1405,10 +1405,10 @@ BOOST_AUTO_TEST_CASE(empty_in_named_args)
{
char const* sourceCode = R"(
contract test {
- function a(uint a, uint b) returns (uint r) {
+ function a(uint a, uint b) public returns (uint r) {
r = a + b;
}
- function b() returns (uint r) {
+ function b() public returns (uint r) {
r = a({});
}
}
@@ -1420,10 +1420,10 @@ BOOST_AUTO_TEST_CASE(duplicate_parameter_names_in_named_args)
{
char const* sourceCode = R"(
contract test {
- function a(uint a, uint b) returns (uint r) {
+ function a(uint a, uint b) public returns (uint r) {
r = a + b;
}
- function b() returns (uint r) {
+ function b() public returns (uint r) {
r = a({a: 1, a: 2});
}
}
@@ -1435,10 +1435,10 @@ BOOST_AUTO_TEST_CASE(invalid_parameter_names_in_named_args)
{
char const* sourceCode = R"(
contract test {
- function a(uint a, uint b) returns (uint r) {
+ function a(uint a, uint b) public returns (uint r) {
r = a + b;
}
- function b() returns (uint r) {
+ function b() public returns (uint r) {
r = a({a: 1, c: 2});
}
}
@@ -1450,7 +1450,7 @@ BOOST_AUTO_TEST_CASE(empty_name_input_parameter)
{
char const* text = R"(
contract test {
- function f(uint) { }
+ function f(uint) public { }
}
)";
CHECK_SUCCESS(text);
@@ -1460,7 +1460,7 @@ BOOST_AUTO_TEST_CASE(constant_input_parameter)
{
char const* text = R"(
contract test {
- function f(uint[] constant a) { }
+ function f(uint[] constant a) public { }
}
)";
CHECK_ERROR_ALLOW_MULTI(text, TypeError, "Illegal use of \"constant\" specifier.");
@@ -1470,7 +1470,7 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
{
char const* text = R"(
contract test {
- function f() returns(bool) { }
+ function f() public returns (bool) { }
}
)";
CHECK_SUCCESS(text);
@@ -1480,7 +1480,7 @@ BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
{
char const* text = R"(
contract test {
- function f(uint, uint k) returns(uint ret_k) {
+ function f(uint, uint k) public returns (uint ret_k) {
return k;
}
}
@@ -1492,7 +1492,7 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter_with_named_one)
{
char const* text = R"(
contract test {
- function f() returns(uint ret_k, uint) {
+ function f() public returns (uint ret_k, uint) {
return 5;
}
}
@@ -1504,7 +1504,7 @@ BOOST_AUTO_TEST_CASE(disallow_declaration_of_void_type)
{
char const* sourceCode = R"(
contract c {
- function f() { var (x) = f(); }
+ function f() public { var (x) = f(); }
}
)";
CHECK_ERROR(sourceCode, TypeError, "Not enough components (0) in value to assign all variables (1).");
@@ -1514,7 +1514,7 @@ BOOST_AUTO_TEST_CASE(overflow_caused_by_ether_units)
{
char const* sourceCodeFine = R"(
contract c {
- function c () {
+ function c () public {
a = 115792089237316195423570985008687907853269984665640564039458;
}
uint256 a;
@@ -1523,7 +1523,7 @@ BOOST_AUTO_TEST_CASE(overflow_caused_by_ether_units)
CHECK_SUCCESS(sourceCodeFine);
char const* sourceCode = R"(
contract c {
- function c () {
+ function c () public {
a = 115792089237316195423570985008687907853269984665640564039458 ether;
}
uint256 a;
@@ -1536,7 +1536,7 @@ BOOST_AUTO_TEST_CASE(exp_operator_exponent_too_big)
{
char const* sourceCode = R"(
contract test {
- function f() returns(uint d) { return 2 ** 10000000000; }
+ function f() public returns (uint d) { return 2 ** 10000000000; }
}
)";
CHECK_ERROR(sourceCode, TypeError, "Operator ** not compatible with types int_const 2 and int_const 10000000000");
@@ -1546,7 +1546,7 @@ BOOST_AUTO_TEST_CASE(exp_warn_literal_base)
{
char const* sourceCode = R"(
contract test {
- function f() pure returns(uint) {
+ function f() pure public returns(uint) {
uint8 x = 100;
return 10**x;
}
@@ -1555,7 +1555,7 @@ BOOST_AUTO_TEST_CASE(exp_warn_literal_base)
CHECK_WARNING(sourceCode, "might overflow");
sourceCode = R"(
contract test {
- function f() pure returns(uint) {
+ function f() pure public returns(uint) {
uint8 x = 100;
return uint8(10)**x;
}
@@ -1564,7 +1564,7 @@ BOOST_AUTO_TEST_CASE(exp_warn_literal_base)
CHECK_SUCCESS(sourceCode);
sourceCode = R"(
contract test {
- function f() pure returns(uint) {
+ function f() pure public returns(uint) {
return 2**80;
}
}
@@ -1576,7 +1576,7 @@ BOOST_AUTO_TEST_CASE(shift_warn_literal_base)
{
char const* sourceCode = R"(
contract test {
- function f() pure returns(uint) {
+ function f() pure public returns(uint) {
uint8 x = 100;
return 10 << x;
}
@@ -1585,7 +1585,7 @@ BOOST_AUTO_TEST_CASE(shift_warn_literal_base)
CHECK_WARNING(sourceCode, "might overflow");
sourceCode = R"(
contract test {
- function f() pure returns(uint) {
+ function f() pure public returns(uint) {
uint8 x = 100;
return uint8(10) << x;
}
@@ -1594,7 +1594,7 @@ BOOST_AUTO_TEST_CASE(shift_warn_literal_base)
CHECK_SUCCESS(sourceCode);
sourceCode = R"(
contract test {
- function f() pure returns(uint) {
+ function f() pure public returns(uint) {
return 2 << 80;
}
}
@@ -1602,7 +1602,7 @@ BOOST_AUTO_TEST_CASE(shift_warn_literal_base)
CHECK_SUCCESS(sourceCode);
sourceCode = R"(
contract test {
- function f() pure returns(uint) {
+ function f() pure public returns(uint) {
uint8 x = 100;
return 10 >> x;
}
@@ -1615,7 +1615,7 @@ BOOST_AUTO_TEST_CASE(warn_var_from_zero)
{
char const* sourceCode = R"(
contract test {
- function f() pure returns (uint) {
+ function f() pure public returns (uint) {
var i = 1;
return i;
}
@@ -1624,7 +1624,7 @@ BOOST_AUTO_TEST_CASE(warn_var_from_zero)
CHECK_WARNING(sourceCode, "uint8, which can hold values between 0 and 255");
sourceCode = R"(
contract test {
- function f() pure {
+ function f() pure public {
var i = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
i;
}
@@ -1633,7 +1633,7 @@ BOOST_AUTO_TEST_CASE(warn_var_from_zero)
CHECK_WARNING(sourceCode, "uint256, which can hold values between 0 and 115792089237316195423570985008687907853269984665640564039457584007913129639935");
sourceCode = R"(
contract test {
- function f() pure {
+ function f() pure public {
var i = -2;
i;
}
@@ -1642,7 +1642,7 @@ BOOST_AUTO_TEST_CASE(warn_var_from_zero)
CHECK_WARNING(sourceCode, "int8, which can hold values between -128 and 127");
sourceCode = R"(
contract test {
- function f() pure {
+ function f() pure public {
for (var i = 0; i < msg.data.length; i++) { }
}
}
@@ -1672,7 +1672,7 @@ BOOST_AUTO_TEST_CASE(enum_member_access_accross_contracts)
enum MyEnum { One, Two }
}
contract Impl {
- function test() returns (Interface.MyEnum) {
+ function test() public returns (Interface.MyEnum) {
return Interface.MyEnum.One;
}
}
@@ -1685,7 +1685,7 @@ BOOST_AUTO_TEST_CASE(enum_invalid_member_access)
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test() {
+ function test() public {
choices = ActionChoices.RunAroundWavingYourHands;
}
ActionChoices choices;
@@ -1699,7 +1699,7 @@ BOOST_AUTO_TEST_CASE(enum_invalid_direct_member_access)
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test() {
+ function test() public {
choices = Sit;
}
ActionChoices choices;
@@ -1713,7 +1713,7 @@ BOOST_AUTO_TEST_CASE(enum_explicit_conversion_is_okay)
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test() {
+ function test() public {
a = uint256(ActionChoices.GoStraight);
b = uint64(ActionChoices.Sit);
}
@@ -1729,7 +1729,7 @@ BOOST_AUTO_TEST_CASE(int_to_enum_explicit_conversion_is_okay)
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test() {
+ function test() public {
a = 2;
b = ActionChoices(a);
}
@@ -1745,7 +1745,7 @@ BOOST_AUTO_TEST_CASE(enum_implicit_conversion_is_not_okay_256)
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test() {
+ function test() public {
a = ActionChoices.GoStraight;
}
uint256 a;
@@ -1759,7 +1759,7 @@ BOOST_AUTO_TEST_CASE(enum_implicit_conversion_is_not_okay_64)
char const* text = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- function test() {
+ function test() public {
b = ActionChoices.Sit;
}
uint64 b;
@@ -1774,7 +1774,7 @@ BOOST_AUTO_TEST_CASE(enum_to_enum_conversion_is_not_okay)
contract test {
enum Paper { Up, Down, Left, Right }
enum Ground { North, South, West, East }
- function test() {
+ function test() public {
Ground(Paper.Up);
}
}
@@ -1801,7 +1801,7 @@ BOOST_AUTO_TEST_CASE(enum_name_resolution_under_current_contract_name)
Second
}
- function a() {
+ function a() public {
A.Foo;
}
}
@@ -1816,7 +1816,7 @@ BOOST_AUTO_TEST_CASE(private_visibility)
function f() private {}
}
contract derived is base {
- function g() { f(); }
+ function g() public { f(); }
}
)";
CHECK_ERROR(sourceCode, DeclarationError, "Undeclared identifier.");
@@ -1829,7 +1829,7 @@ BOOST_AUTO_TEST_CASE(private_visibility_via_explicit_base_access)
function f() private {}
}
contract derived is base {
- function g() { base.f(); }
+ function g() public { base.f(); }
}
)";
CHECK_ERROR(sourceCode, TypeError, "Member \"f\" not found or not visible after argument-dependent lookup in type(contract base)");
@@ -1840,7 +1840,7 @@ BOOST_AUTO_TEST_CASE(external_visibility)
char const* sourceCode = R"(
contract c {
function f() external {}
- function g() { f(); }
+ function g() public { f(); }
}
)";
CHECK_ERROR(sourceCode, DeclarationError, "Undeclared identifier.");
@@ -1853,7 +1853,7 @@ BOOST_AUTO_TEST_CASE(external_base_visibility)
function f() external {}
}
contract derived is base {
- function g() { base.f(); }
+ function g() public { base.f(); }
}
)";
CHECK_ERROR(sourceCode, TypeError, "Member \"f\" not found or not visible after argument-dependent lookup in type(contract base)");
@@ -1906,7 +1906,7 @@ BOOST_AUTO_TEST_CASE(array_with_nonconstant_length)
{
char const* text = R"(
contract c {
- function f(uint a) { uint8[a] x; }
+ function f(uint a) public { uint8[a] x; }
}
)";
CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal.");
@@ -1916,7 +1916,7 @@ BOOST_AUTO_TEST_CASE(array_with_negative_length)
{
char const* text = R"(
contract c {
- function f(uint a) { uint8[-1] x; }
+ function f(uint a) public { uint8[-1] x; }
}
)";
CHECK_ERROR(text, TypeError, "Array with negative length specified");
@@ -1928,7 +1928,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types1)
contract c {
bytes a;
uint[] b;
- function f() { b = a; }
+ function f() public { b = a; }
}
)";
CHECK_ERROR(text, TypeError, "Type bytes storage ref is not implicitly convertible to expected type uint256[] storage ref.");
@@ -1940,7 +1940,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types2)
contract c {
uint32[] a;
uint8[] b;
- function f() { b = a; }
+ function f() public { b = a; }
}
)";
CHECK_ERROR(text, TypeError, "Type uint32[] storage ref is not implicitly convertible to expected type uint8[] storage ref.");
@@ -1952,7 +1952,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types_conversion_possible)
contract c {
uint32[] a;
uint8[] b;
- function f() { a = b; }
+ function f() public { a = b; }
}
)";
CHECK_SUCCESS(text);
@@ -1964,7 +1964,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types_static_dynamic)
contract c {
uint32[] a;
uint8[80] b;
- function f() { a = b; }
+ function f() public { a = b; }
}
)";
CHECK_SUCCESS(text);
@@ -1976,7 +1976,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types_dynamic_static)
contract c {
uint[] a;
uint[80] b;
- function f() { b = a; }
+ function f() public { b = a; }
}
)";
CHECK_ERROR(text, TypeError, "Type uint256[] storage ref is not implicitly convertible to expected type uint256[80] storage ref.");
@@ -2116,7 +2116,7 @@ BOOST_AUTO_TEST_CASE(test_byte_is_alias_of_byte1)
char const* text = R"(
contract c {
bytes arr;
- function f() { byte a = arr[0];}
+ function f() public { byte a = arr[0];}
}
)";
CHECK_SUCCESS(text);
@@ -2156,7 +2156,7 @@ BOOST_AUTO_TEST_CASE(assigning_value_to_const_variable)
{
char const* text = R"(
contract Foo {
- function changeIt() { x = 9; }
+ function changeIt() public { x = 9; }
uint constant x = 56;
}
)";
@@ -2179,7 +2179,7 @@ BOOST_AUTO_TEST_CASE(constant_string_literal_disallows_assignment)
char const* text = R"(
contract Test {
string constant x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca";
- function f() {
+ function f() public {
x[0] = "f";
}
}
@@ -2277,9 +2277,9 @@ BOOST_AUTO_TEST_CASE(overloaded_function_cannot_resolve)
{
char const* sourceCode = R"(
contract test {
- function f() returns(uint) { return 1; }
- function f(uint a) returns(uint) { return a; }
- function g() returns(uint) { return f(3, 5); }
+ function f() public returns (uint) { return 1; }
+ function f(uint a) public returns (uint) { return a; }
+ function g() public returns (uint) { return f(3, 5); }
}
)";
CHECK_ERROR(sourceCode, TypeError, "No matching declaration found after argument-dependent lookup.");
@@ -2290,9 +2290,9 @@ BOOST_AUTO_TEST_CASE(ambiguous_overloaded_function)
// literal 1 can be both converted to uint and uint8, so the call is ambiguous.
char const* sourceCode = R"(
contract test {
- function f(uint8 a) returns(uint) { return a; }
- function f(uint a) returns(uint) { return 2*a; }
- function g() returns(uint) { return f(1); }
+ function f(uint8 a) public returns (uint) { return a; }
+ function f(uint a) public returns (uint) { return 2*a; }
+ function g() public returns (uint) { return f(1); }
}
)";
CHECK_ERROR(sourceCode, TypeError, "No unique declaration found after argument-dependent lookup.");
@@ -2302,8 +2302,8 @@ BOOST_AUTO_TEST_CASE(assignment_of_nonoverloaded_function)
{
char const* sourceCode = R"(
contract test {
- function f(uint a) returns(uint) { return 2 * a; }
- function g() returns(uint) { var x = f; return x(7); }
+ function f(uint a) public returns (uint) { return 2 * a; }
+ function g() public returns (uint) { var x = f; return x(7); }
}
)";
CHECK_SUCCESS(sourceCode);
@@ -2313,9 +2313,9 @@ BOOST_AUTO_TEST_CASE(assignment_of_overloaded_function)
{
char const* sourceCode = R"(
contract test {
- function f() returns(uint) { return 1; }
- function f(uint a) returns(uint) { return 2 * a; }
- function g() returns(uint) { var x = f; return x(7); }
+ function f() public returns (uint) { return 1; }
+ function f(uint a) public returns (uint) { return 2 * a; }
+ function g() public returns (uint) { var x = f; return x(7); }
}
)";
CHECK_ERROR(sourceCode, TypeError, "No matching declaration found after variable lookup.");
@@ -2326,10 +2326,10 @@ BOOST_AUTO_TEST_CASE(external_types_clash)
char const* sourceCode = R"(
contract base {
enum a { X }
- function f(a) { }
+ function f(a) public { }
}
contract test is base {
- function f(uint8 a) { }
+ function f(uint8 a) public { }
}
)";
CHECK_ERROR(sourceCode, TypeError, "Function overload clash during conversion to external types for arguments.");
@@ -2339,10 +2339,10 @@ BOOST_AUTO_TEST_CASE(override_changes_return_types)
{
char const* sourceCode = R"(
contract base {
- function f(uint a) returns (uint) { }
+ function f(uint a) public returns (uint) { }
}
contract test is base {
- function f(uint a) returns (uint8) { }
+ function f(uint a) public returns (uint8) { }
}
)";
CHECK_ERROR(sourceCode, TypeError, "Overriding function return types differ");
@@ -2352,8 +2352,8 @@ BOOST_AUTO_TEST_CASE(multiple_constructors)
{
char const* sourceCode = R"(
contract test {
- function test(uint a) { }
- function test() {}
+ function test(uint a) public { }
+ function test() public {}
}
)";
CHECK_ERROR(sourceCode, DeclarationError, "More than one constructor defined");
@@ -2363,7 +2363,7 @@ BOOST_AUTO_TEST_CASE(equal_overload)
{
char const* sourceCode = R"(
contract C {
- function test(uint a) returns (uint b) { }
+ function test(uint a) public returns (uint b) { }
function test(uint a) external {}
}
)";
@@ -2374,7 +2374,7 @@ BOOST_AUTO_TEST_CASE(uninitialized_var)
{
char const* sourceCode = R"(
contract C {
- function f() returns (uint) { var x; return 2; }
+ function f() public returns (uint) { var x; return 2; }
}
)";
CHECK_ERROR(sourceCode, TypeError, "Assignment necessary for type detection.");
@@ -2426,7 +2426,7 @@ BOOST_AUTO_TEST_CASE(string_index)
char const* sourceCode = R"(
contract C {
string s;
- function f() { var a = s[2]; }
+ function f() public { var a = s[2]; }
}
)";
CHECK_ERROR(sourceCode, TypeError, "Index access for string is not possible.");
@@ -2437,7 +2437,7 @@ BOOST_AUTO_TEST_CASE(string_length)
char const* sourceCode = R"(
contract C {
string s;
- function f() { var a = s.length; }
+ function f() public { var a = s.length; }
}
)";
CHECK_ERROR(sourceCode, TypeError, "Member \"length\" not found or not visible after argument-dependent lookup in string storage ref");
@@ -2506,15 +2506,15 @@ BOOST_AUTO_TEST_CASE(positive_integers_to_unsigned_out_of_bound)
BOOST_AUTO_TEST_CASE(integer_boolean_operators)
{
char const* sourceCode1 = R"(
- contract test { function() { uint x = 1; uint y = 2; x || y; } }
+ contract test { function() public { uint x = 1; uint y = 2; x || y; } }
)";
CHECK_ERROR(sourceCode1, TypeError, "Operator || not compatible with types uint256 and uint256");
char const* sourceCode2 = R"(
- contract test { function() { uint x = 1; uint y = 2; x && y; } }
+ contract test { function() public { uint x = 1; uint y = 2; x && y; } }
)";
CHECK_ERROR(sourceCode2, TypeError, "Operator && not compatible with types uint256 and uint256");
char const* sourceCode3 = R"(
- contract test { function() { uint x = 1; !x; } }
+ contract test { function() public { uint x = 1; !x; } }
)";
CHECK_ERROR(sourceCode3, TypeError, "Unary operator ! cannot be applied to type uint256");
}
@@ -2522,15 +2522,15 @@ BOOST_AUTO_TEST_CASE(integer_boolean_operators)
BOOST_AUTO_TEST_CASE(exp_signed_variable)
{
char const* sourceCode1 = R"(
- contract test { function() { uint x = 3; int y = -4; x ** y; } }
+ contract test { function() public { uint x = 3; int y = -4; x ** y; } }
)";
CHECK_ERROR(sourceCode1, TypeError, "Operator ** not compatible with types uint256 and int256");
char const* sourceCode2 = R"(
- contract test { function() { uint x = 3; int y = -4; y ** x; } }
+ contract test { function() public { uint x = 3; int y = -4; y ** x; } }
)";
CHECK_ERROR(sourceCode2, TypeError, "Operator ** not compatible with types int256 and uint256");
char const* sourceCode3 = R"(
- contract test { function() { int x = -3; int y = -4; x ** y; } }
+ contract test { function() public { int x = -3; int y = -4; x ** y; } }
)";
CHECK_ERROR(sourceCode3, TypeError, "Operator ** not compatible with types int256 and int256");
}
@@ -2538,11 +2538,11 @@ BOOST_AUTO_TEST_CASE(exp_signed_variable)
BOOST_AUTO_TEST_CASE(reference_compare_operators)
{
char const* sourceCode1 = R"(
- contract test { bytes a; bytes b; function() { a == b; } }
+ contract test { bytes a; bytes b; function() public { a == b; } }
)";
CHECK_ERROR(sourceCode1, TypeError, "Operator == not compatible with types bytes storage ref and bytes storage ref");
char const* sourceCode2 = R"(
- contract test { struct s {uint a;} s x; s y; function() { x == y; } }
+ contract test { struct s {uint a;} s x; s y; function() public { x == y; } }
)";
CHECK_ERROR(sourceCode2, TypeError, "Operator == not compatible with types struct test.s storage ref and struct test.s storage ref");
}
@@ -2571,7 +2571,7 @@ BOOST_AUTO_TEST_CASE(storage_location_local_variables)
{
char const* sourceCode = R"(
contract C {
- function f() {
+ function f() public {
uint[] storage x;
uint[] memory y;
uint[] memory z;
@@ -2586,7 +2586,7 @@ BOOST_AUTO_TEST_CASE(no_mappings_in_memory_array)
{
char const* sourceCode = R"(
contract C {
- function f() {
+ function f() public {
mapping(uint=>uint)[] memory x;
}
}
@@ -2599,7 +2599,7 @@ BOOST_AUTO_TEST_CASE(assignment_mem_to_local_storage_variable)
char const* sourceCode = R"(
contract C {
uint[] data;
- function f(uint[] x) {
+ function f(uint[] x) public {
var dataRef = data;
dataRef = x;
}
@@ -2614,7 +2614,7 @@ BOOST_AUTO_TEST_CASE(storage_assign_to_different_local_variable)
contract C {
uint[] data;
uint8[] otherData;
- function f() {
+ function f() public {
uint8[] storage x = otherData;
uint[] storage y = data;
y = x;
@@ -2629,7 +2629,7 @@ BOOST_AUTO_TEST_CASE(uninitialized_mapping_variable)
{
char const* sourceCode = R"(
contract C {
- function f() {
+ function f() public {
mapping(uint => uint) x;
x;
}
@@ -2642,7 +2642,7 @@ BOOST_AUTO_TEST_CASE(uninitialized_mapping_array_variable)
{
char const* sourceCode = R"(
contract C {
- function f() pure {
+ function f() pure public {
mapping(uint => uint)[] storage x;
x;
}
@@ -2656,7 +2656,7 @@ BOOST_AUTO_TEST_CASE(no_delete_on_storage_pointers)
char const* sourceCode = R"(
contract C {
uint[] data;
- function f() {
+ function f() public {
var x = data;
delete x;
}
@@ -2670,7 +2670,7 @@ BOOST_AUTO_TEST_CASE(assignment_mem_storage_variable_directly)
char const* sourceCode = R"(
contract C {
uint[] data;
- function f(uint[] x) {
+ function f(uint[] x) public {
data = x;
}
}
@@ -2684,7 +2684,7 @@ BOOST_AUTO_TEST_CASE(function_argument_mem_to_storage)
contract C {
function f(uint[] storage x) private {
}
- function g(uint[] x) {
+ function g(uint[] x) public {
f(x);
}
}
@@ -2699,7 +2699,7 @@ BOOST_AUTO_TEST_CASE(function_argument_storage_to_mem)
function f(uint[] storage x) private {
g(x);
}
- function g(uint[] x) {
+ function g(uint[] x) public {
}
}
)";
@@ -2725,8 +2725,8 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible)
{
char const* sourceCode = R"(
contract C {
- function f(uint) returns (string);
- function g() {
+ function f(uint) public returns (string);
+ function g() public {
var (x,) = this.f(2);
// we can assign to x but it is not usable.
bytes(x).length;
@@ -2740,7 +2740,7 @@ BOOST_AUTO_TEST_CASE(memory_arrays_not_resizeable)
{
char const* sourceCode = R"(
contract C {
- function f() {
+ function f() public {
uint[] memory x;
x.length = 2;
}
@@ -2754,7 +2754,7 @@ BOOST_AUTO_TEST_CASE(struct_constructor)
char const* sourceCode = R"(
contract C {
struct S { uint a; bool x; }
- function f() {
+ function f() public {
S memory s = S(1, true);
}
}
@@ -2768,7 +2768,7 @@ BOOST_AUTO_TEST_CASE(struct_constructor_nested)
contract C {
struct X { uint x1; uint x2; }
struct S { uint s1; uint[3] s2; X s3; }
- function f() {
+ function f() public {
uint[3] memory s2;
S memory s = S(1, s2, X(4, 5));
}
@@ -2782,7 +2782,7 @@ BOOST_AUTO_TEST_CASE(struct_named_constructor)
char const* sourceCode = R"(
contract C {
struct S { uint a; bool x; }
- function f() {
+ function f() public {
S memory s = S({a: 1, x: true});
}
}
@@ -2794,7 +2794,7 @@ BOOST_AUTO_TEST_CASE(literal_strings)
{
char const* text = R"(
contract Foo {
- function f() {
+ function f() public {
string memory long = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
string memory short = "123";
long; short;
@@ -2810,7 +2810,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_with_mappings)
contract Test {
struct S { uint8 a; mapping(uint => uint) b; uint8 c; }
S s;
- function f() {
+ function f() public {
S memory x;
x.b[1];
}
@@ -2884,10 +2884,10 @@ BOOST_AUTO_TEST_CASE(call_to_library_function)
{
char const* text = R"(
library Lib {
- function min(uint, uint) returns (uint);
+ function min(uint, uint) public returns (uint);
}
contract Test {
- function f() {
+ function f() public {
uint t = Lib.min(12, 7);
}
}
@@ -2899,7 +2899,7 @@ BOOST_AUTO_TEST_CASE(creating_contract_within_the_contract)
{
char const* sourceCode = R"(
contract Test {
- function f() { var x = new Test(); }
+ function f() public { var x = new Test(); }
}
)";
CHECK_ERROR(sourceCode, TypeError, "Circular reference for contract creation (cannot create instance of derived or same contract).");
@@ -2910,7 +2910,7 @@ BOOST_AUTO_TEST_CASE(array_out_of_bound_access)
char const* text = R"(
contract c {
uint[2] dataArray;
- function set5th() returns (bool) {
+ function set5th() public returns (bool) {
dataArray[5] = 2;
return true;
}
@@ -2923,7 +2923,7 @@ BOOST_AUTO_TEST_CASE(literal_string_to_storage_pointer)
{
char const* text = R"(
contract C {
- function f() { string x = "abc"; }
+ function f() public { string x = "abc"; }
}
)";
CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type string storage pointer.");
@@ -2934,11 +2934,10 @@ BOOST_AUTO_TEST_CASE(non_initialized_references)
char const* text = R"(
contract c
{
- struct s{
+ struct s {
uint a;
}
- function f()
- {
+ function f() public {
s storage x;
x.a = 2;
}
@@ -2953,7 +2952,7 @@ BOOST_AUTO_TEST_CASE(keccak256_with_large_integer_constant)
char const* text = R"(
contract c
{
- function f() { keccak256(2**500); }
+ function f() public { keccak256(2**500); }
}
)";
CHECK_ERROR(text, TypeError, "Invalid rational number (too large or division by zero).");
@@ -2962,9 +2961,9 @@ BOOST_AUTO_TEST_CASE(keccak256_with_large_integer_constant)
BOOST_AUTO_TEST_CASE(cyclic_binary_dependency)
{
char const* text = R"(
- contract A { function f() { new B(); } }
- contract B { function f() { new C(); } }
- contract C { function f() { new A(); } }
+ contract A { function f() public { new B(); } }
+ contract B { function f() public { new C(); } }
+ contract C { function f() public { new A(); } }
)";
CHECK_ERROR(text, TypeError, "Circular reference for contract creation (cannot create instance of derived or same contract).");
}
@@ -2973,8 +2972,8 @@ BOOST_AUTO_TEST_CASE(cyclic_binary_dependency_via_inheritance)
{
char const* text = R"(
contract A is B { }
- contract B { function f() { new C(); } }
- contract C { function f() { new A(); } }
+ contract B { function f() public { new C(); } }
+ contract C { function f() public { new A(); } }
)";
CHECK_ERROR(text, TypeError, "Definition of base has to precede definition of derived contract");
}
@@ -2982,7 +2981,7 @@ BOOST_AUTO_TEST_CASE(cyclic_binary_dependency_via_inheritance)
BOOST_AUTO_TEST_CASE(multi_variable_declaration_fail)
{
char const* text = R"(
- contract C { function f() { var (x,y); x = 1; y = 1;} }
+ contract C { function f() public { var (x,y); x = 1; y = 1;} }
)";
CHECK_ERROR(text, TypeError, "Assignment necessary for type detection.");
}
@@ -2991,10 +2990,10 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fine)
{
char const* text = R"(
contract C {
- function three() returns (uint, uint, uint);
- function two() returns (uint, uint);
+ function three() public returns (uint, uint, uint);
+ function two() public returns (uint, uint);
function none();
- function f() {
+ function f() public {
var (a,) = three();
var (b,c,) = two();
var (,d) = three();
@@ -3012,8 +3011,8 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_1)
{
char const* text = R"(
contract C {
- function one() returns (uint);
- function f() { var (a, b, ) = one(); }
+ function one() public returns (uint);
+ function f() public { var (a, b, ) = one(); }
}
)";
CHECK_ERROR(text, TypeError, "Not enough components (1) in value to assign all variables (2).");
@@ -3022,8 +3021,8 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_2)
{
char const* text = R"(
contract C {
- function one() returns (uint);
- function f() { var (a, , ) = one(); }
+ function one() public returns (uint);
+ function f() public { var (a, , ) = one(); }
}
)";
CHECK_ERROR(text, TypeError, "Not enough components (1) in value to assign all variables (2).");
@@ -3033,8 +3032,8 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_3)
{
char const* text = R"(
contract C {
- function one() returns (uint);
- function f() { var (, , a) = one(); }
+ function one() public returns (uint);
+ function f() public { var (, , a) = one(); }
}
)";
CHECK_ERROR(text, TypeError, "Not enough components (1) in value to assign all variables (2).");
@@ -3044,8 +3043,8 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_4)
{
char const* text = R"(
contract C {
- function one() returns (uint);
- function f() { var (, a, b) = one(); }
+ function one() public returns (uint);
+ function f() public { var (, a, b) = one(); }
}
)";
CHECK_ERROR(text, TypeError, "Not enough components (1) in value to assign all variables (2).");
@@ -3055,7 +3054,7 @@ BOOST_AUTO_TEST_CASE(tuples)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
uint a = (1);
var (b,) = (uint8(1),);
var (c,d) = (uint32(1), 2 + a);
@@ -3071,7 +3070,7 @@ BOOST_AUTO_TEST_CASE(tuples_empty_components)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
(1,,2);
}
}
@@ -3083,8 +3082,8 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_5)
{
char const* text = R"(
contract C {
- function one() returns (uint);
- function f() { var (,) = one(); }
+ function one() public returns (uint);
+ function f() public { var (,) = one(); }
}
)";
CHECK_ERROR(text, TypeError, "Wildcard both at beginning and end of variable declaration list is only allowed if the number of components is equal.");
@@ -3094,8 +3093,8 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_6)
{
char const* text = R"(
contract C {
- function two() returns (uint, uint);
- function f() { var (a, b, c) = two(); }
+ function two() public returns (uint, uint);
+ function f() public { var (a, b, c) = two(); }
}
)";
CHECK_ERROR(text, TypeError, "Not enough components (2) in value to assign all variables (3)");
@@ -3105,8 +3104,8 @@ BOOST_AUTO_TEST_CASE(tuple_assignment_from_void_function)
{
char const* text = R"(
contract C {
- function f() { }
- function g() {
+ function f() public { }
+ function g() public {
var (x,) = (f(), f());
}
}
@@ -3118,7 +3117,7 @@ BOOST_AUTO_TEST_CASE(tuple_compound_assignment)
{
char const* text = R"(
contract C {
- function f() returns (uint a, uint b) {
+ function f() public returns (uint a, uint b) {
(a, b) += (1, 1);
}
}
@@ -3133,7 +3132,7 @@ BOOST_AUTO_TEST_CASE(member_access_parser_ambiguity)
struct R { uint[10][10] y; }
struct S { uint a; uint b; uint[20][20][20] c; R d; }
S data;
- function f() {
+ function f() public {
C.S x = data;
C.S memory y;
C.S[10] memory z;
@@ -3172,10 +3171,10 @@ BOOST_AUTO_TEST_CASE(using_for_not_library)
BOOST_AUTO_TEST_CASE(using_for_function_exists)
{
char const* text = R"(
- library D { function double(uint self) returns (uint) { return 2*self; } }
+ library D { function double(uint self) public returns (uint) { return 2*self; } }
contract C {
using D for uint;
- function f(uint a) {
+ function f(uint a) public {
a.double;
}
}
@@ -3186,10 +3185,10 @@ BOOST_AUTO_TEST_CASE(using_for_function_exists)
BOOST_AUTO_TEST_CASE(using_for_function_on_int)
{
char const* text = R"(
- library D { function double(uint self) returns (uint) { return 2*self; } }
+ library D { function double(uint self) public returns (uint) { return 2*self; } }
contract C {
using D for uint;
- function f(uint a) returns (uint) {
+ function f(uint a) public returns (uint) {
return a.double();
}
}
@@ -3200,11 +3199,11 @@ BOOST_AUTO_TEST_CASE(using_for_function_on_int)
BOOST_AUTO_TEST_CASE(using_for_function_on_struct)
{
char const* text = R"(
- library D { struct s { uint a; } function mul(s storage self, uint x) returns (uint) { return self.a *= x; } }
+ library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } }
contract C {
using D for D.s;
D.s x;
- function f(uint a) returns (uint) {
+ function f(uint a) public returns (uint) {
return x.mul(a);
}
}
@@ -3217,13 +3216,13 @@ BOOST_AUTO_TEST_CASE(using_for_overload)
char const* text = R"(
library D {
struct s { uint a; }
- function mul(s storage self, uint x) returns (uint) { return self.a *= x; }
- function mul(s storage, bytes32) returns (bytes32) { }
+ function mul(s storage self, uint x) public returns (uint) { return self.a *= x; }
+ function mul(s storage, bytes32) public returns (bytes32) { }
}
contract C {
using D for D.s;
D.s x;
- function f(uint a) returns (uint) {
+ function f(uint a) public returns (uint) {
return x.mul(a);
}
}
@@ -3234,11 +3233,11 @@ BOOST_AUTO_TEST_CASE(using_for_overload)
BOOST_AUTO_TEST_CASE(using_for_by_name)
{
char const* text = R"(
- library D { struct s { uint a; } function mul(s storage self, uint x) returns (uint) { return self.a *= x; } }
+ library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } }
contract C {
using D for D.s;
D.s x;
- function f(uint a) returns (uint) {
+ function f(uint a) public returns (uint) {
return x.mul({x: a});
}
}
@@ -3249,10 +3248,10 @@ BOOST_AUTO_TEST_CASE(using_for_by_name)
BOOST_AUTO_TEST_CASE(using_for_mismatch)
{
char const* text = R"(
- library D { function double(bytes32 self) returns (uint) { return 2; } }
+ library D { function double(bytes32 self) public returns (uint) { return 2; } }
contract C {
using D for uint;
- function f(uint a) returns (uint) {
+ function f(uint a) public returns (uint) {
return a.double();
}
}
@@ -3265,10 +3264,10 @@ BOOST_AUTO_TEST_CASE(using_for_not_used)
// This is an error because the function is only bound to uint.
// Had it been bound to *, it would have worked.
char const* text = R"(
- library D { function double(uint self) returns (uint) { return 2; } }
+ library D { function double(uint self) public returns (uint) { return 2; } }
contract C {
using D for uint;
- function f(uint16 a) returns (uint) {
+ function f(uint16 a) public returns (uint) {
return a.double();
}
}
@@ -3281,7 +3280,7 @@ BOOST_AUTO_TEST_CASE(library_memory_struct)
char const* text = R"(
library c {
struct S { uint x; }
- function f() returns (S ) {}
+ function f() public returns (S ) {}
}
)";
CHECK_ERROR(text, TypeError, "Internal type is not allowed for public or external functions.");
@@ -3291,10 +3290,10 @@ BOOST_AUTO_TEST_CASE(using_for_arbitrary_mismatch)
{
// Bound to a, but self type does not match.
char const* text = R"(
- library D { function double(bytes32 self) returns (uint) { return 2; } }
+ library D { function double(bytes32 self) public returns (uint) { return 2; } }
contract C {
using D for *;
- function f(uint a) returns (uint) {
+ function f(uint a) public returns (uint) {
return a.double();
}
}
@@ -3305,11 +3304,11 @@ BOOST_AUTO_TEST_CASE(using_for_arbitrary_mismatch)
BOOST_AUTO_TEST_CASE(bound_function_in_var)
{
char const* text = R"(
- library D { struct s { uint a; } function mul(s storage self, uint x) returns (uint) { return self.a *= x; } }
+ library D { struct s { uint a; } function mul(s storage self, uint x) public returns (uint) { return self.a *= x; } }
contract C {
using D for D.s;
D.s x;
- function f(uint a) returns (uint) {
+ function f(uint a) public returns (uint) {
var g = x.mul;
return g({x: a});
}
@@ -3326,7 +3325,7 @@ BOOST_AUTO_TEST_CASE(create_memory_arrays)
struct S { uint a; uint b; uint[20][20][20] c; R d; }
}
contract C {
- function f(uint size) {
+ function f(uint size) public {
L.S[][] memory x = new L.S[][](10);
var y = new uint[](20);
var z = new bytes(size);
@@ -3341,7 +3340,7 @@ BOOST_AUTO_TEST_CASE(mapping_in_memory_array)
{
char const* text = R"(
contract C {
- function f(uint size) {
+ function f(uint size) public {
var x = new mapping(uint => uint)[](4);
}
}
@@ -3353,7 +3352,7 @@ BOOST_AUTO_TEST_CASE(new_for_non_array)
{
char const* text = R"(
contract C {
- function f(uint size) {
+ function f(uint size) public {
var x = new uint(7);
}
}
@@ -3365,7 +3364,7 @@ BOOST_AUTO_TEST_CASE(invalid_args_creating_memory_array)
{
char const* text = R"(
contract C {
- function f(uint size) {
+ function f(uint size) public {
var x = new uint[]();
}
}
@@ -3388,7 +3387,7 @@ BOOST_AUTO_TEST_CASE(inline_array_declaration_and_passing_implicit_conversion)
{
char const* text = R"(
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
uint8 x = 7;
uint16 y = 8;
uint32 z = 9;
@@ -3404,7 +3403,7 @@ BOOST_AUTO_TEST_CASE(inline_array_declaration_and_passing_implicit_conversion_st
{
char const* text = R"(
contract C {
- function f() returns (string) {
+ function f() public returns (string) {
string memory x = "Hello";
string memory y = "World";
string[2] memory z = [x, y];
@@ -3419,7 +3418,7 @@ BOOST_AUTO_TEST_CASE(inline_array_declaration_const_int_conversion)
{
char const* text = R"(
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
uint8[4] memory z = [1,2,3,5];
return (z[0]);
}
@@ -3432,7 +3431,7 @@ BOOST_AUTO_TEST_CASE(inline_array_declaration_const_string_conversion)
{
char const* text = R"(
contract C {
- function f() returns (string) {
+ function f() public returns (string) {
string[2] memory z = ["Hello", "World"];
return (z[0]);
}
@@ -3445,7 +3444,7 @@ BOOST_AUTO_TEST_CASE(inline_array_declaration_no_type)
{
char const* text = R"(
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
return ([4,5,6][1]);
}
}
@@ -3457,7 +3456,7 @@ BOOST_AUTO_TEST_CASE(inline_array_declaration_no_type_strings)
{
char const* text = R"(
contract C {
- function f() returns (string) {
+ function f() public returns (string) {
return (["foo", "man", "choo"][1]);
}
}
@@ -3485,7 +3484,7 @@ BOOST_AUTO_TEST_CASE(invalid_types_in_inline_array)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
uint[3] x = [45, 'foo', true];
}
}
@@ -3497,7 +3496,7 @@ BOOST_AUTO_TEST_CASE(dynamic_inline_array)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
uint8[4][4] memory dyn = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]];
}
}
@@ -3509,7 +3508,7 @@ BOOST_AUTO_TEST_CASE(lvalues_as_inline_array)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
[1, 2, 3]++;
[1, 2, 3] = [4, 5, 6];
}
@@ -3522,7 +3521,7 @@ BOOST_AUTO_TEST_CASE(break_not_in_loop)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
if (true)
break;
}
@@ -3535,7 +3534,7 @@ BOOST_AUTO_TEST_CASE(continue_not_in_loop)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
if (true)
continue;
}
@@ -3548,7 +3547,7 @@ BOOST_AUTO_TEST_CASE(continue_not_in_loop_2)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
while (true)
{
}
@@ -3563,7 +3562,7 @@ BOOST_AUTO_TEST_CASE(invalid_different_types_for_conditional_expression)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
true ? true : 2;
}
}
@@ -3575,7 +3574,7 @@ BOOST_AUTO_TEST_CASE(left_value_in_conditional_expression_not_supported_yet)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
uint x;
uint y;
(true ? x : y) = 1;
@@ -3595,7 +3594,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_different_struct)
struct s2 {
uint x;
}
- function f() {
+ function f() public {
s1 memory x;
s2 memory y;
true ? x : y;
@@ -3609,10 +3608,10 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_different_function_type)
{
char const* text = R"(
contract C {
- function x(bool) {}
- function y() {}
+ function x(bool) public {}
+ function y() public {}
- function f() {
+ function f() public {
true ? x : y;
}
}
@@ -3627,7 +3626,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_different_enum)
enum small { A, B, C, D }
enum big { A, B, C, D }
- function f() {
+ function f() public {
small x;
big y;
@@ -3645,7 +3644,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_different_mapping)
mapping(uint8 => uint8) table1;
mapping(uint32 => uint8) table2;
- function f() {
+ function f() public {
true ? table1 : table2;
}
}
@@ -3663,15 +3662,15 @@ BOOST_AUTO_TEST_CASE(conditional_with_all_types)
s1 struct_x;
s1 struct_y;
- function fun_x() {}
- function fun_y() {}
+ function fun_x() public {}
+ function fun_y() public {}
enum small { A, B, C, D }
mapping(uint8 => uint8) table1;
mapping(uint8 => uint8) table2;
- function f() {
+ function f() public {
// integers
uint x;
uint y;
@@ -3686,7 +3685,7 @@ BOOST_AUTO_TEST_CASE(conditional_with_all_types)
var i = true ? "hello" : "world";
i = "used"; //Avoid unused var warning
}
- function f2() {
+ function f2() public {
// bool
bool j = true ? true : false;
j = j && true; // Avoid unused var warning
@@ -3711,7 +3710,7 @@ BOOST_AUTO_TEST_CASE(conditional_with_all_types)
m &= m;
}
- function f3() {
+ function f3() public {
// contract doesn't fit in here
// struct
@@ -3765,7 +3764,7 @@ BOOST_AUTO_TEST_CASE(index_access_for_bytes)
char const* text = R"(
contract C {
bytes20 x;
- function f(bytes16 b) {
+ function f(bytes16 b) public {
b[uint(x[2])];
}
}
@@ -3778,7 +3777,7 @@ BOOST_AUTO_TEST_CASE(uint7_and_uintM_as_identifier)
char const* text = R"(
contract test {
string uintM = "Hello 4 you";
- function f() {
+ function f() public {
uint8 uint7 = 3;
uint7 = 5;
string memory intM;
@@ -3794,7 +3793,7 @@ BOOST_AUTO_TEST_CASE(varM_disqualified_as_keyword)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
uintM something = 3;
intM should = 4;
bytesM fail = "now";
@@ -3808,7 +3807,7 @@ BOOST_AUTO_TEST_CASE(long_uint_variable_fails)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
uint99999999999999999999999999 something = 3;
}
}
@@ -3820,7 +3819,7 @@ BOOST_AUTO_TEST_CASE(bytes10abc_is_identifier)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
bytes32 bytes10abc = "abc";
}
}
@@ -3832,7 +3831,7 @@ BOOST_AUTO_TEST_CASE(int10abc_is_identifier)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
uint uint10abc = 3;
int int10abc = 4;
uint10abc; int10abc;
@@ -3845,9 +3844,9 @@ BOOST_AUTO_TEST_CASE(int10abc_is_identifier)
BOOST_AUTO_TEST_CASE(library_functions_do_not_have_value)
{
char const* text = R"(
- library L { function l() {} }
+ library L { function l() public {} }
contract test {
- function f() {
+ function f() public {
L.l.value;
}
}
@@ -3888,9 +3887,9 @@ BOOST_AUTO_TEST_CASE(invalid_fixed_types_7x8_mxn)
BOOST_AUTO_TEST_CASE(library_instances_cannot_be_used)
{
char const* text = R"(
- library L { function l() {} }
+ library L { function l() public {} }
contract test {
- function f() {
+ function f() public {
L x;
x.l();
}
@@ -3903,7 +3902,7 @@ BOOST_AUTO_TEST_CASE(invalid_fixed_type_long)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
fixed8x888888888888888888888888888888888888888888888888888 b;
}
}
@@ -3915,7 +3914,7 @@ BOOST_AUTO_TEST_CASE(fixed_type_int_conversion)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
uint64 a = 3;
int64 b = 4;
fixed c = b;
@@ -3931,7 +3930,7 @@ BOOST_AUTO_TEST_CASE(fixed_type_rational_int_conversion)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
fixed c = 3;
ufixed d = 4;
c; d;
@@ -3945,7 +3944,7 @@ BOOST_AUTO_TEST_CASE(fixed_type_rational_fraction_conversion)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
fixed a = 4.5;
ufixed d = 2.5;
a; d;
@@ -3959,7 +3958,7 @@ BOOST_AUTO_TEST_CASE(invalid_int_implicit_conversion_from_fixed)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
fixed a = 4.5;
int b = a;
a; b;
@@ -3973,7 +3972,7 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation)
{
char const* text = R"(
contract test {
- function f() pure {
+ function f() pure public {
ufixed16x2 a = 3.25;
fixed16x2 b = -3.25;
a; b;
@@ -3983,7 +3982,7 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation)
CHECK_SUCCESS_NO_WARNINGS(text);
text = R"(
contract test {
- function f() pure {
+ function f() pure public {
ufixed16x2 a = +3.25;
fixed16x2 b = -3.25;
a; b;
@@ -3993,7 +3992,7 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation)
CHECK_WARNING(text, "Use of unary + is deprecated");
text = R"(
contract test {
- function f(uint x) pure {
+ function f(uint x) pure public {
uint y = +x;
y;
}
@@ -4006,7 +4005,7 @@ BOOST_AUTO_TEST_CASE(leading_zero_rationals_convert)
{
char const* text = R"(
contract A {
- function f() pure {
+ function f() pure public {
ufixed16x2 a = 0.5;
ufixed256x52 b = 0.0000000000000006661338147750939242541790008544921875;
fixed16x2 c = -0.5;
@@ -4022,7 +4021,7 @@ BOOST_AUTO_TEST_CASE(size_capabilities_of_fixed_point_types)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
ufixed256x1 a = 123456781234567979695948382928485849359686494864095409282048094275023098123.5;
ufixed256x77 b = 0.920890746623327805482905058466021565416131529487595827354393978494366605267637;
ufixed224x78 c = 0.000000000001519884736399797998492268541131529487595827354393978494366605267646;
@@ -4040,7 +4039,7 @@ BOOST_AUTO_TEST_CASE(zero_handling)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
fixed16x2 a = 0; a;
ufixed32x1 b = 0; b;
}
@@ -4053,7 +4052,7 @@ BOOST_AUTO_TEST_CASE(fixed_type_invalid_implicit_conversion_size)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
ufixed a = 11/4;
ufixed248x8 b = a; b;
}
@@ -4066,7 +4065,7 @@ BOOST_AUTO_TEST_CASE(fixed_type_invalid_implicit_conversion_lost_data)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
ufixed256x1 a = 1/3; a;
}
}
@@ -4078,7 +4077,7 @@ BOOST_AUTO_TEST_CASE(fixed_type_valid_explicit_conversions)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
ufixed256x80 a = ufixed256x80(1/3); a;
ufixed248x80 b = ufixed248x80(1/3); b;
ufixed8x1 c = ufixed8x1(1/3); c;
@@ -4092,7 +4091,7 @@ BOOST_AUTO_TEST_CASE(invalid_array_declaration_with_rational)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
uint[3.5] a; a;
}
}
@@ -4104,7 +4103,7 @@ BOOST_AUTO_TEST_CASE(invalid_array_declaration_with_signed_fixed_type)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
uint[fixed(3.5)] a; a;
}
}
@@ -4116,7 +4115,7 @@ BOOST_AUTO_TEST_CASE(invalid_array_declaration_with_unsigned_fixed_type)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
uint[ufixed(3.5)] a; a;
}
}
@@ -4128,7 +4127,7 @@ BOOST_AUTO_TEST_CASE(rational_to_bytes_implicit_conversion)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
bytes32 c = 3.2; c;
}
}
@@ -4140,7 +4139,7 @@ BOOST_AUTO_TEST_CASE(fixed_to_bytes_implicit_conversion)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
fixed a = 3.25;
bytes32 c = a; c;
}
@@ -4154,7 +4153,7 @@ BOOST_AUTO_TEST_CASE(mapping_with_fixed_literal)
char const* text = R"(
contract test {
mapping(ufixed8x1 => string) fixedString;
- function f() {
+ function f() public {
fixedString[0.5] = "Half";
}
}
@@ -4180,7 +4179,7 @@ BOOST_AUTO_TEST_CASE(inline_array_fixed_types)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
fixed[3] memory a = [fixed(3.5), fixed(-4.25), fixed(967.125)];
}
}
@@ -4192,7 +4191,7 @@ BOOST_AUTO_TEST_CASE(inline_array_rationals)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
ufixed128x3[4] memory a = [ufixed128x3(3.5), 4.125, 2.5, 4.0];
}
}
@@ -4204,7 +4203,7 @@ BOOST_AUTO_TEST_CASE(rational_index_access)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
uint[] memory a;
a[.5];
}
@@ -4217,7 +4216,7 @@ BOOST_AUTO_TEST_CASE(rational_to_fixed_literal_expression)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
ufixed64x8 a = 3.5 * 3;
ufixed64x8 b = 4 - 2.5;
ufixed64x8 c = 11 / 4;
@@ -4236,7 +4235,7 @@ BOOST_AUTO_TEST_CASE(rational_as_exponent_value_signed)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
fixed g = 2 ** -2.2;
}
}
@@ -4248,7 +4247,7 @@ BOOST_AUTO_TEST_CASE(rational_as_exponent_value_unsigned)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
ufixed b = 3 ** 2.5;
}
}
@@ -4260,7 +4259,7 @@ BOOST_AUTO_TEST_CASE(rational_as_exponent_half)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
2 ** (1/2);
}
}
@@ -4272,7 +4271,7 @@ BOOST_AUTO_TEST_CASE(rational_as_exponent_value_neg_quarter)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
42 ** (-1/4);
}
}
@@ -4284,7 +4283,7 @@ BOOST_AUTO_TEST_CASE(fixed_point_casting_exponents_15)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
var a = 3 ** ufixed(1.5);
}
}
@@ -4296,7 +4295,7 @@ BOOST_AUTO_TEST_CASE(fixed_point_casting_exponents_neg)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
var c = 42 ** fixed(-1/4);
}
}
@@ -4308,7 +4307,7 @@ BOOST_AUTO_TEST_CASE(var_capable_of_holding_constant_rationals)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
var a = 0.12345678;
var b = 12345678.352;
var c = 0.00000009;
@@ -4323,7 +4322,7 @@ BOOST_AUTO_TEST_CASE(var_and_rational_with_tuple)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
var (a, b) = (.5, 1/3);
a; b;
}
@@ -4336,7 +4335,7 @@ BOOST_AUTO_TEST_CASE(var_handle_divided_integers)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
var x = 1/3;
}
}
@@ -4348,7 +4347,7 @@ BOOST_AUTO_TEST_CASE(rational_bitnot_unary_operation)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
~fixed(3.5);
}
}
@@ -4360,7 +4359,7 @@ BOOST_AUTO_TEST_CASE(rational_bitor_binary_operation)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
fixed(1.5) | 3;
}
}
@@ -4372,7 +4371,7 @@ BOOST_AUTO_TEST_CASE(rational_bitxor_binary_operation)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
fixed(1.75) ^ 3;
}
}
@@ -4384,7 +4383,7 @@ BOOST_AUTO_TEST_CASE(rational_bitand_binary_operation)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
fixed(1.75) & 3;
}
}
@@ -4396,7 +4395,7 @@ BOOST_AUTO_TEST_CASE(missing_bool_conversion)
{
char const* text = R"(
contract test {
- function b(uint a) {
+ function b(uint a) public {
bool(a == 1);
}
}
@@ -4408,7 +4407,7 @@ BOOST_AUTO_TEST_CASE(integer_and_fixed_interaction)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
ufixed a = uint64(1) + ufixed(2);
}
}
@@ -4420,7 +4419,7 @@ BOOST_AUTO_TEST_CASE(signed_rational_modulus)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
fixed a = 0.42578125 % -0.4271087646484375;
fixed b = .5 % a;
fixed c = a % b;
@@ -4434,7 +4433,7 @@ BOOST_AUTO_TEST_CASE(one_divided_by_three_integer_conversion)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
uint a = 1/3;
}
}
@@ -4446,8 +4445,8 @@ BOOST_AUTO_TEST_CASE(unused_return_value)
{
char const* text = R"(
contract test {
- function g() returns (uint) {}
- function f() {
+ function g() public returns (uint) {}
+ function f() public {
g();
}
}
@@ -4459,7 +4458,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_send)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
address(0x12).send(1);
}
}
@@ -4471,7 +4470,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_call)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
address(0x12).call("abc");
}
}
@@ -4483,7 +4482,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_call_value)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
address(0x12).call.value(2)("abc");
}
}
@@ -4495,7 +4494,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_callcode)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
address(0x12).callcode("abc");
}
}
@@ -4507,7 +4506,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_delegatecall)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
address(0x12).delegatecall("abc");
}
}
@@ -4519,7 +4518,7 @@ BOOST_AUTO_TEST_CASE(warn_about_callcode)
{
char const* text = R"(
contract test {
- function f() pure {
+ function f() pure public {
var x = address(0x12).callcode;
x;
}
@@ -4532,7 +4531,7 @@ BOOST_AUTO_TEST_CASE(no_warn_about_callcode_as_function)
{
char const* text = R"(
contract test {
- function callcode() pure {
+ function callcode() pure public {
test.callcode();
}
}
@@ -4554,7 +4553,7 @@ BOOST_AUTO_TEST_CASE(payable_in_library)
{
char const* text = R"(
library test {
- function f() payable {}
+ function f() payable public {}
}
)";
CHECK_ERROR(text, TypeError, "Library functions cannot be payable.");
@@ -4593,8 +4592,8 @@ BOOST_AUTO_TEST_CASE(payable_private)
BOOST_AUTO_TEST_CASE(illegal_override_payable)
{
char const* text = R"(
- contract B { function f() payable {} }
- contract C is B { function f() {} }
+ contract B { function f() payable public {} }
+ contract C is B { function f() public {} }
)";
CHECK_ERROR(text, TypeError, "Overriding function changes state mutability from \"payable\" to \"nonpayable\".");
}
@@ -4602,8 +4601,8 @@ BOOST_AUTO_TEST_CASE(illegal_override_payable)
BOOST_AUTO_TEST_CASE(illegal_override_payable_nonpayable)
{
char const* text = R"(
- contract B { function f() {} }
- contract C is B { function f() payable {} }
+ contract B { function f() public {} }
+ contract C is B { function f() payable public {} }
)";
CHECK_ERROR(text, TypeError, "Overriding function changes state mutability from \"nonpayable\" to \"payable\".");
}
@@ -4616,11 +4615,11 @@ BOOST_AUTO_TEST_CASE(function_variable_mixin)
bool ok = false;
}
contract func {
- function ok() returns (bool) { return true; }
+ function ok() public returns (bool) { return true; }
}
contract attr_func is attribute, func {
- function checkOk() returns (bool) { return ok(); }
+ function checkOk() public returns (bool) { return ok(); }
}
)";
CHECK_ERROR(text, DeclarationError, "Identifier already declared.");
@@ -4629,11 +4628,11 @@ BOOST_AUTO_TEST_CASE(function_variable_mixin)
BOOST_AUTO_TEST_CASE(calling_payable)
{
char const* text = R"(
- contract receiver { function pay() payable {} }
+ contract receiver { function pay() payable public {} }
contract test {
- function f() { (new receiver()).pay.value(10)(); }
+ function f() public { (new receiver()).pay.value(10)(); }
receiver r = new receiver();
- function g() { r.pay.value(10)(); }
+ function g() public { r.pay.value(10)(); }
}
)";
CHECK_SUCCESS(text);
@@ -4642,9 +4641,9 @@ BOOST_AUTO_TEST_CASE(calling_payable)
BOOST_AUTO_TEST_CASE(calling_nonpayable)
{
char const* text = R"(
- contract receiver { function nopay() {} }
+ contract receiver { function nopay() public {} }
contract test {
- function f() { (new receiver()).nopay.value(10)(); }
+ function f() public { (new receiver()).nopay.value(10)(); }
}
)";
CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup in function () external - did you forget the \"payable\" modifier?");
@@ -4657,7 +4656,7 @@ BOOST_AUTO_TEST_CASE(non_payable_constructor)
function C() { }
}
contract D {
- function f() returns (uint) {
+ function f() public returns (uint) {
(new C).value(2)();
return 2;
}
@@ -4687,7 +4686,7 @@ BOOST_AUTO_TEST_CASE(unsatisfied_version)
BOOST_CHECK(searchErrorMessage(*sourceAndError.second, "Source file requires different compiler version"));
}
-BOOST_AUTO_TEST_CASE(constant_constructor)
+BOOST_AUTO_TEST_CASE(invalid_constructor_statemutability)
{
char const* text = R"(
contract test {
@@ -4695,6 +4694,18 @@ BOOST_AUTO_TEST_CASE(constant_constructor)
}
)";
CHECK_ERROR(text, TypeError, "Constructor must be payable or non-payable");
+ text = R"(
+ contract test {
+ function test() view {}
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Constructor must be payable or non-payable");
+ text = R"(
+ contract test {
+ function test() pure {}
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Constructor must be payable or non-payable");
}
BOOST_AUTO_TEST_CASE(external_constructor)
@@ -4712,7 +4723,7 @@ BOOST_AUTO_TEST_CASE(invalid_array_as_statement)
char const* text = R"(
contract test {
struct S { uint x; }
- function test(uint k) { S[k]; }
+ function test(uint k) public { S[k]; }
}
)";
CHECK_ERROR(text, TypeError, "Integer constant expected.");
@@ -4722,13 +4733,13 @@ BOOST_AUTO_TEST_CASE(using_directive_for_missing_selftype)
{
char const* text = R"(
library B {
- function b() {}
+ function b() public {}
}
contract A {
using B for bytes;
- function a() {
+ function a() public {
bytes memory x;
x.b();
}
@@ -4741,7 +4752,7 @@ BOOST_AUTO_TEST_CASE(function_type)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
function(uint) returns (uint) x;
}
}
@@ -4753,7 +4764,7 @@ BOOST_AUTO_TEST_CASE(function_type_parameter)
{
char const* text = R"(
contract C {
- function f(function(uint) external returns (uint) g) returns (function(uint) external returns (uint)) {
+ function f(function(uint) external returns (uint) g) public returns (function(uint) external returns (uint)) {
return g;
}
}
@@ -4765,7 +4776,7 @@ BOOST_AUTO_TEST_CASE(function_type_returned)
{
char const* text = R"(
contract C {
- function f() returns (function(uint) external returns (uint) g) {
+ function f() public returns (function(uint) external returns (uint) g) {
return g;
}
}
@@ -4777,7 +4788,7 @@ BOOST_AUTO_TEST_CASE(private_function_type)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
function(uint) private returns (uint) x;
}
}
@@ -4789,7 +4800,7 @@ BOOST_AUTO_TEST_CASE(public_function_type)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
function(uint) public returns (uint) x;
}
}
@@ -4812,7 +4823,7 @@ BOOST_AUTO_TEST_CASE(call_value_on_non_payable_function_type)
char const* text = R"(
contract C {
function (uint) external returns (uint) x;
- function f() {
+ function f() public {
x.value(2)();
}
}
@@ -4845,7 +4856,7 @@ BOOST_AUTO_TEST_CASE(call_value_on_payable_function_type)
char const* text = R"(
contract C {
function (uint) external payable returns (uint) x;
- function f() {
+ function f() public {
x.value(2)(1);
}
}
@@ -4859,7 +4870,7 @@ BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter)
// as parameters to external functions.
char const* text = R"(
contract C {
- function f(function(uint) internal returns (uint) x) {
+ function f(function(uint) internal returns (uint) x) public {
}
}
)";
@@ -4871,7 +4882,7 @@ BOOST_AUTO_TEST_CASE(internal_function_returned_from_public_function)
// It should not be possible to return internal functions from external functions.
char const* text = R"(
contract C {
- function f() returns (function(uint) internal returns (uint) x) {
+ function f() public returns (function(uint) internal returns (uint) x) {
}
}
)";
@@ -4893,7 +4904,7 @@ BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter_in_library_external
{
char const* text = R"(
library L {
- function f(function(uint) internal returns (uint) x) {
+ function f(function(uint) internal returns (uint) x) public {
}
}
)";
@@ -4906,7 +4917,7 @@ BOOST_AUTO_TEST_CASE(function_type_arrays)
contract C {
function(uint) external returns (uint)[] public x;
function(uint) internal returns (uint)[10] y;
- function f() {
+ function f() public {
function(uint) returns (uint)[10] memory a;
function(uint) returns (uint)[10] storage b = y;
function(uint) external returns (uint)[] memory c;
@@ -4924,7 +4935,7 @@ BOOST_AUTO_TEST_CASE(delete_function_type)
contract C {
function(uint) external returns (uint) x;
function(uint) internal returns (uint) y;
- function f() {
+ function f() public {
delete x;
var a = y;
delete a;
@@ -4943,7 +4954,7 @@ BOOST_AUTO_TEST_CASE(delete_function_type_invalid)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
delete f;
}
}
@@ -4955,7 +4966,7 @@ BOOST_AUTO_TEST_CASE(delete_external_function_type_invalid)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
delete this.f;
}
}
@@ -4970,9 +4981,9 @@ BOOST_AUTO_TEST_CASE(external_function_to_function_type_calldata_parameter)
// when converting to a function type.
char const* text = R"(
contract C {
- function f(function(bytes memory) external g) { }
+ function f(function(bytes memory) external g) public { }
function callback(bytes) external {}
- function g() {
+ function g() public {
f(this.callback);
}
}
@@ -4984,7 +4995,7 @@ BOOST_AUTO_TEST_CASE(external_function_type_to_address)
{
char const* text = R"(
contract C {
- function f() returns (address) {
+ function f() public returns (address) {
return address(this.f);
}
}
@@ -4996,7 +5007,7 @@ BOOST_AUTO_TEST_CASE(internal_function_type_to_address)
{
char const* text = R"(
contract C {
- function f() returns (address) {
+ function f() public returns (address) {
return address(f);
}
}
@@ -5008,7 +5019,7 @@ BOOST_AUTO_TEST_CASE(external_function_type_to_uint)
{
char const* text = R"(
contract C {
- function f() returns (uint) {
+ function f() public returns (uint) {
return uint(this.f);
}
}
@@ -5030,7 +5041,7 @@ BOOST_AUTO_TEST_CASE(warn_function_type_return_parameters_with_names)
{
char const* text = R"(
contract C {
- function(uint) returns(bool ret) f;
+ function(uint) returns (bool ret) f;
}
)";
CHECK_WARNING(text, "Naming function type return parameters is deprecated.");
@@ -5080,7 +5091,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_positive_stack)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
assembly {
1
}
@@ -5094,7 +5105,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_negative_stack)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
assembly {
pop
}
@@ -5109,7 +5120,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_two_stack_load)
char const* text = R"(
contract c {
uint8 x;
- function f() {
+ function f() public {
assembly { x pop }
}
}
@@ -5140,7 +5151,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage)
char const* text = R"(
contract test {
uint x = 1;
- function f() {
+ function f() public {
assembly {
x := 2
}
@@ -5173,7 +5184,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_constant_assign)
char const* text = R"(
contract test {
uint constant x = 1;
- function f() {
+ function f() public {
assembly {
x := 2
}
@@ -5188,7 +5199,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_constant_access)
char const* text = R"(
contract test {
uint constant x = 1;
- function f() {
+ function f() public {
assembly {
let y := x
}
@@ -5202,7 +5213,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_local_variable_access_out_of_functions)
{
char const* text = R"(
contract test {
- function f() {
+ function f() public {
uint a;
assembly {
function g() -> x { x := a }
@@ -5218,7 +5229,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_local_variable_access_out_of_functions_stor
char const* text = R"(
contract test {
uint[] r;
- function f() {
+ function f() public {
uint[] storage a = r;
assembly {
function g() -> x { x := a_offset }
@@ -5234,7 +5245,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_variable_access_out_of_functions)
char const* text = R"(
contract test {
uint a;
- function f() pure {
+ function f() pure public {
assembly {
function g() -> x { x := a_slot }
}
@@ -5262,7 +5273,7 @@ BOOST_AUTO_TEST_CASE(invalid_mobile_type)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
// Invalid number
[1, 78901234567890123456789012345678901234567890123456789345678901234567890012345678012345678901234567];
}
@@ -5275,7 +5286,7 @@ BOOST_AUTO_TEST_CASE(warns_msg_value_in_non_payable_public_function)
{
char const* text = R"(
contract C {
- function f() view {
+ function f() view public {
msg.value;
}
}
@@ -5287,7 +5298,7 @@ BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_payable_function)
{
char const* text = R"(
contract C {
- function f() payable {
+ function f() payable public {
msg.value;
}
}
@@ -5311,7 +5322,7 @@ BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_library)
{
char const* text = R"(
library C {
- function f() view {
+ function f() view public {
msg.value;
}
}
@@ -5323,7 +5334,7 @@ BOOST_AUTO_TEST_CASE(does_not_warn_msg_value_in_modifier_following_non_payable_p
{
char const* text = R"(
contract c {
- function f() pure { }
+ function f() pure public { }
modifier m() { msg.value; _; }
}
)";
@@ -5335,7 +5346,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_constant)
char const* text = R"(
contract c {
uint constant a = 1;
- function f() { a = 2; }
+ function f() public { a = 2; }
}
)";
CHECK_ERROR(text, TypeError, "Cannot assign to a constant variable.");
@@ -5348,7 +5359,7 @@ BOOST_AUTO_TEST_CASE(inconstructible_internal_constructor)
function C() internal {}
}
contract D {
- function f() { var x = new C(); }
+ function f() public { var x = new C(); }
}
)";
CHECK_ERROR(text, TypeError, "Contract with internal constructor cannot be created directly.");
@@ -5361,7 +5372,7 @@ BOOST_AUTO_TEST_CASE(inconstructible_internal_constructor_inverted)
char const* text = R"(
contract B {
A a;
- function B() {
+ function B() public {
a = new A(this);
}
}
@@ -5379,7 +5390,7 @@ BOOST_AUTO_TEST_CASE(constructible_internal_constructor)
function C() internal {}
}
contract D is C {
- function D() { }
+ function D() public { }
}
)";
success(text);
@@ -5389,7 +5400,7 @@ BOOST_AUTO_TEST_CASE(address_checksum_type_deduction)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
var x = 0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E;
x.send(2);
}
@@ -5402,7 +5413,7 @@ BOOST_AUTO_TEST_CASE(invalid_address_checksum)
{
char const* text = R"(
contract C {
- function f() pure {
+ function f() pure public {
address x = 0xFA0bFc97E48458494Ccd857e1A85DC91F7F0046E;
x;
}
@@ -5415,7 +5426,7 @@ BOOST_AUTO_TEST_CASE(invalid_address_no_checksum)
{
char const* text = R"(
contract C {
- function f() pure {
+ function f() pure public {
address x = 0xfa0bfc97e48458494ccd857e1a85dc91f7f0046e;
x;
}
@@ -5428,7 +5439,7 @@ BOOST_AUTO_TEST_CASE(invalid_address_length)
{
char const* text = R"(
contract C {
- function f() pure {
+ function f() pure public {
address x = 0xA0bFc97E48458494Ccd857e1A85DC91F7F0046E;
x;
}
@@ -5448,7 +5459,7 @@ BOOST_AUTO_TEST_CASE(address_test_for_bug_in_implementation)
CHECK_ERROR(text, TypeError, "is not implicitly convertible to expected type address");
text = R"(
contract AddrString {
- function f() returns (address) {
+ function f() public returns (address) {
return "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c";
}
}
@@ -5476,7 +5487,7 @@ BOOST_AUTO_TEST_CASE(address_methods)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
address addr;
uint balance = addr.balance;
bool callRet = addr.call();
@@ -5553,7 +5564,7 @@ BOOST_AUTO_TEST_CASE(interface_function_bodies)
{
char const* text = R"(
interface I {
- function f() {
+ function f() public {
}
}
)";
@@ -5627,7 +5638,7 @@ BOOST_AUTO_TEST_CASE(interface_function_parameters)
{
char const* text = R"(
interface I {
- function f(uint a) returns(bool);
+ function f(uint a) public returns (bool);
}
)";
success(text);
@@ -5650,7 +5661,7 @@ BOOST_AUTO_TEST_CASE(using_interface)
function f();
}
contract C is I {
- function f() {
+ function f() public {
}
}
)";
@@ -5667,7 +5678,7 @@ BOOST_AUTO_TEST_CASE(using_interface_complex)
function();
}
contract C is I {
- function f() {
+ function f() public {
}
}
)";
@@ -5678,7 +5689,7 @@ BOOST_AUTO_TEST_CASE(warn_about_throw)
{
char const* text = R"(
contract C {
- function f() pure {
+ function f() pure public {
throw;
}
}
@@ -5690,7 +5701,7 @@ BOOST_AUTO_TEST_CASE(bare_revert)
{
char const* text = R"(
contract C {
- function f(uint x) pure {
+ function f(uint x) pure public {
if (x > 7)
revert;
}
@@ -5701,17 +5712,17 @@ BOOST_AUTO_TEST_CASE(bare_revert)
BOOST_AUTO_TEST_CASE(bare_others)
{
- CHECK_WARNING("contract C { function f() pure { selfdestruct; } }", "Statement has no effect.");
- CHECK_WARNING("contract C { function f() pure { assert; } }", "Statement has no effect.");
- CHECK_WARNING("contract C { function f() pure { require; } }", "Statement has no effect.");
- CHECK_WARNING("contract C { function f() pure { suicide; } }", "Statement has no effect.");
+ CHECK_WARNING("contract C { function f() pure public { selfdestruct; } }", "Statement has no effect.");
+ CHECK_WARNING("contract C { function f() pure public { assert; } }", "Statement has no effect.");
+ CHECK_WARNING("contract C { function f() pure public { require; } }", "Statement has no effect.");
+ CHECK_WARNING("contract C { function f() pure public { suicide; } }", "Statement has no effect.");
}
BOOST_AUTO_TEST_CASE(pure_statement_in_for_loop)
{
char const* text = R"(
contract C {
- function f() pure {
+ function f() pure public {
for (uint x = 0; x < 10; true)
x++;
}
@@ -5724,7 +5735,7 @@ BOOST_AUTO_TEST_CASE(pure_statement_check_for_regular_for_loop)
{
char const* text = R"(
contract C {
- function f() pure {
+ function f() pure public {
for (uint x = 0; true; x++)
{}
}
@@ -5739,7 +5750,7 @@ BOOST_AUTO_TEST_CASE(warn_multiple_storage_storage_copies)
contract C {
struct S { uint a; uint b; }
S x; S y;
- function f() {
+ function f() public {
(x, y) = (y, x);
}
}
@@ -5753,7 +5764,7 @@ BOOST_AUTO_TEST_CASE(warn_multiple_storage_storage_copies_fill_right)
contract C {
struct S { uint a; uint b; }
S x; S y;
- function f() {
+ function f() public {
(x, y, ) = (y, x, 1, 2);
}
}
@@ -5767,7 +5778,7 @@ BOOST_AUTO_TEST_CASE(warn_multiple_storage_storage_copies_fill_left)
contract C {
struct S { uint a; uint b; }
S x; S y;
- function f() {
+ function f() public {
(,x, y) = (1, 2, y, x);
}
}
@@ -5780,7 +5791,7 @@ BOOST_AUTO_TEST_CASE(nowarn_swap_memory)
char const* text = R"(
contract C {
struct S { uint a; uint b; }
- function f() pure {
+ function f() pure public {
S memory x;
S memory y;
(x, y) = (y, x);
@@ -5796,7 +5807,7 @@ BOOST_AUTO_TEST_CASE(nowarn_swap_storage_pointers)
contract C {
struct S { uint a; uint b; }
S x; S y;
- function f() {
+ function f() public {
S storage x_local = x;
S storage y_local = y;
S storage z_local = x;
@@ -5811,7 +5822,7 @@ BOOST_AUTO_TEST_CASE(warn_unused_local)
{
char const* text = R"(
contract C {
- function f() pure {
+ function f() pure public {
uint a;
}
}
@@ -5823,7 +5834,7 @@ BOOST_AUTO_TEST_CASE(warn_unused_local_assigned)
{
char const* text = R"(
contract C {
- function f() pure {
+ function f() pure public {
uint a = 1;
}
}
@@ -5835,14 +5846,14 @@ BOOST_AUTO_TEST_CASE(warn_unused_function_parameter)
{
char const* text = R"(
contract C {
- function f(uint a) pure {
+ function f(uint a) pure public {
}
}
)";
CHECK_WARNING(text, "Unused function parameter. Remove or comment out the variable name to silence this warning.");
text = R"(
contract C {
- function f(uint a) pure {
+ function f(uint a) pure public {
}
}
)";
@@ -5853,14 +5864,14 @@ BOOST_AUTO_TEST_CASE(warn_unused_return_parameter)
{
char const* text = R"(
contract C {
- function f() pure returns (uint a) {
+ function f() pure public returns (uint a) {
}
}
)";
CHECK_WARNING(text, "Unused function parameter. Remove or comment out the variable name to silence this warning.");
text = R"(
contract C {
- function f() pure returns (uint a) {
+ function f() pure public returns (uint a) {
return;
}
}
@@ -5868,14 +5879,14 @@ BOOST_AUTO_TEST_CASE(warn_unused_return_parameter)
CHECK_WARNING(text, "Unused function parameter. Remove or comment out the variable name to silence this warning.");
text = R"(
contract C {
- function f() pure returns (uint) {
+ function f() pure public returns (uint) {
}
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
text = R"(
contract C {
- function f() pure returns (uint a) {
+ function f() pure public returns (uint a) {
a = 1;
}
}
@@ -5883,7 +5894,7 @@ BOOST_AUTO_TEST_CASE(warn_unused_return_parameter)
CHECK_SUCCESS_NO_WARNINGS(text);
text = R"(
contract C {
- function f() pure returns (uint a) {
+ function f() pure public returns (uint a) {
return 1;
}
}
@@ -5895,7 +5906,7 @@ BOOST_AUTO_TEST_CASE(no_unused_warnings)
{
char const* text = R"(
contract C {
- function f(uint a) pure returns (uint b) {
+ function f(uint a) pure public returns (uint b) {
uint c = 1;
b = a + c;
}
@@ -5908,7 +5919,7 @@ BOOST_AUTO_TEST_CASE(no_unused_dec_after_use)
{
char const* text = R"(
contract C {
- function f() pure {
+ function f() pure public {
a = 7;
uint a;
}
@@ -5921,7 +5932,7 @@ BOOST_AUTO_TEST_CASE(no_unused_inline_asm)
{
char const* text = R"(
contract C {
- function f() pure {
+ function f() pure public {
uint a;
assembly {
a := 1
@@ -5936,7 +5947,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_with_functions)
{
char const* text = R"(
contract C {
- function keccak256() pure {}
+ function keccak256() pure public {}
}
)";
CHECK_WARNING(text, "shadows a builtin symbol");
@@ -5946,7 +5957,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_with_variables)
{
char const* text = R"(
contract C {
- function f() pure {
+ function f() pure public {
uint msg;
msg;
}
@@ -5978,7 +5989,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_with_parameters)
{
char const* text = R"(
contract C {
- function f(uint require) pure {
+ function f(uint require) pure public {
require = 2;
}
}
@@ -5990,7 +6001,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_with_return_parameters)
{
char const* text = R"(
contract C {
- function f() pure returns (uint require) {
+ function f() pure public returns (uint require) {
require = 2;
}
}
@@ -6024,7 +6035,7 @@ BOOST_AUTO_TEST_CASE(shadowing_builtins_ignores_constructor)
{
char const* text = R"(
contract C {
- function C() {}
+ function C() public {}
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
@@ -6034,8 +6045,8 @@ BOOST_AUTO_TEST_CASE(function_overload_is_not_shadowing)
{
char const* text = R"(
contract C {
- function f() pure {}
- function f(uint) pure {}
+ function f() pure public {}
+ function f(uint) pure public {}
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
@@ -6044,9 +6055,9 @@ BOOST_AUTO_TEST_CASE(function_overload_is_not_shadowing)
BOOST_AUTO_TEST_CASE(function_override_is_not_shadowing)
{
char const* text = R"(
- contract D { function f() pure {} }
+ contract D { function f() pure public {} }
contract C is D {
- function f(uint) pure {}
+ function f(uint) pure public {}
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
@@ -6058,7 +6069,7 @@ BOOST_AUTO_TEST_CASE(callable_crash)
contract C {
struct S { uint a; bool x; }
S public s;
- function C() {
+ function C() public {
3({a: 1, x: true});
}
}
@@ -6070,13 +6081,13 @@ BOOST_AUTO_TEST_CASE(error_transfer_non_payable_fallback)
{
char const* text = R"(
contract A {
- function() {}
+ function() public {}
}
contract B {
A a;
- function() {
+ function() public {
a.transfer(100);
}
}
@@ -6092,7 +6103,7 @@ BOOST_AUTO_TEST_CASE(error_transfer_no_fallback)
contract B {
A a;
- function() {
+ function() public {
a.transfer(100);
}
}
@@ -6104,13 +6115,13 @@ BOOST_AUTO_TEST_CASE(error_send_non_payable_fallback)
{
char const* text = R"(
contract A {
- function() {}
+ function() public {}
}
contract B {
A a;
- function() {
+ function() public {
require(a.send(100));
}
}
@@ -6122,13 +6133,13 @@ BOOST_AUTO_TEST_CASE(does_not_error_transfer_payable_fallback)
{
char const* text = R"(
contract A {
- function() payable {}
+ function() payable public {}
}
contract B {
A a;
- function() {
+ function() public {
a.transfer(100);
}
}
@@ -6140,13 +6151,13 @@ BOOST_AUTO_TEST_CASE(does_not_error_transfer_regular_function)
{
char const* text = R"(
contract A {
- function transfer() pure {}
+ function transfer() pure public {}
}
contract B {
A a;
- function() {
+ function() public {
a.transfer();
}
}
@@ -6157,7 +6168,7 @@ BOOST_AUTO_TEST_CASE(does_not_error_transfer_regular_function)
BOOST_AUTO_TEST_CASE(returndatacopy_as_variable)
{
char const* text = R"(
- contract c { function f() { uint returndatasize; assembly { returndatasize }}}
+ contract c { function f() public { uint returndatasize; assembly { returndatasize }}}
)";
CHECK_WARNING_ALLOW_MULTI(text, "Variable is shadowed in inline assembly by an instruction of the same name");
}
@@ -6165,7 +6176,7 @@ BOOST_AUTO_TEST_CASE(returndatacopy_as_variable)
BOOST_AUTO_TEST_CASE(create2_as_variable)
{
char const* text = R"(
- contract c { function f() { uint create2; assembly { create2(0, 0, 0, 0) }}}
+ contract c { function f() public { uint create2; assembly { create2(0, 0, 0, 0) }}}
)";
CHECK_WARNING_ALLOW_MULTI(text, "Variable is shadowed in inline assembly by an instruction of the same name");
}
@@ -6176,7 +6187,7 @@ BOOST_AUTO_TEST_CASE(warn_unspecified_storage)
contract C {
struct S { uint a; string b; }
S x;
- function f() view {
+ function f() view public {
S storage y = x;
y;
}
@@ -6187,7 +6198,7 @@ BOOST_AUTO_TEST_CASE(warn_unspecified_storage)
contract C {
struct S { uint a; }
S x;
- function f() view {
+ function f() view public {
S y = x;
y;
}
@@ -6200,7 +6211,7 @@ BOOST_AUTO_TEST_CASE(implicit_conversion_disallowed)
{
char const* text = R"(
contract C {
- function f() returns (bytes4) {
+ function f() public returns (bytes4) {
uint32 tmp = 1;
return tmp;
}
@@ -6227,7 +6238,7 @@ BOOST_AUTO_TEST_CASE(too_large_arrays_for_calldata)
CHECK_ERROR(text, TypeError, "Array is too large to be encoded.");
text = R"(
contract C {
- function f(uint[85678901234] a) pure {
+ function f(uint[85678901234] a) pure public {
}
}
)";
@@ -6238,7 +6249,7 @@ BOOST_AUTO_TEST_CASE(explicit_literal_to_storage_string)
{
char const* text = R"(
contract C {
- function f() pure {
+ function f() pure public {
string memory x = "abc";
x;
}
@@ -6247,7 +6258,7 @@ BOOST_AUTO_TEST_CASE(explicit_literal_to_storage_string)
CHECK_SUCCESS_NO_WARNINGS(text);
text = R"(
contract C {
- function f() pure {
+ function f() pure public {
string storage x = "abc";
}
}
@@ -6255,7 +6266,7 @@ BOOST_AUTO_TEST_CASE(explicit_literal_to_storage_string)
CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type string storage pointer.");
text = R"(
contract C {
- function f() pure {
+ function f() pure public {
string x = "abc";
}
}
@@ -6263,7 +6274,7 @@ BOOST_AUTO_TEST_CASE(explicit_literal_to_storage_string)
CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type string storage pointer.");
text = R"(
contract C {
- function f() pure {
+ function f() pure public {
string("abc");
}
}
@@ -6316,7 +6327,7 @@ BOOST_AUTO_TEST_CASE(function_types_sig)
CHECK_ERROR(text, TypeError, "Member \"selector\" not found");
text = R"(
contract C {
- function f() view returns (bytes4) {
+ function f() view external returns (bytes4) {
return this.f.selector;
}
}
@@ -6370,10 +6381,10 @@ BOOST_AUTO_TEST_CASE(using_this_in_constructor)
{
char const* text = R"(
contract C {
- function C() {
+ function C() public {
this.f();
}
- function f() pure {
+ function f() pure public {
}
}
)";
@@ -6386,7 +6397,7 @@ BOOST_AUTO_TEST_CASE(do_not_crash_on_not_lvalue)
char const* text = R"(
contract C {
mapping (uint => uint) m;
- function f() {
+ function f() public {
m(1) = 2;
}
}
@@ -6398,7 +6409,7 @@ BOOST_AUTO_TEST_CASE(builtin_reject_gas)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
keccak256.gas();
}
}
@@ -6406,7 +6417,7 @@ BOOST_AUTO_TEST_CASE(builtin_reject_gas)
CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup");
text = R"(
contract C {
- function f() {
+ function f() public {
sha256.gas();
}
}
@@ -6414,7 +6425,7 @@ BOOST_AUTO_TEST_CASE(builtin_reject_gas)
CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup");
text = R"(
contract C {
- function f() {
+ function f() public {
ripemd160.gas();
}
}
@@ -6422,7 +6433,7 @@ BOOST_AUTO_TEST_CASE(builtin_reject_gas)
CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup");
text = R"(
contract C {
- function f() {
+ function f() public {
ecrecover.gas();
}
}
@@ -6434,7 +6445,7 @@ BOOST_AUTO_TEST_CASE(builtin_reject_value)
{
char const* text = R"(
contract C {
- function f() {
+ function f() public {
keccak256.value();
}
}
@@ -6442,7 +6453,7 @@ BOOST_AUTO_TEST_CASE(builtin_reject_value)
CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup");
text = R"(
contract C {
- function f() {
+ function f() public {
sha256.value();
}
}
@@ -6450,7 +6461,7 @@ BOOST_AUTO_TEST_CASE(builtin_reject_value)
CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup");
text = R"(
contract C {
- function f() {
+ function f() public {
ripemd160.value();
}
}
@@ -6458,7 +6469,7 @@ BOOST_AUTO_TEST_CASE(builtin_reject_value)
CHECK_ERROR(text, TypeError, "Member \"value\" not found or not visible after argument-dependent lookup");
text = R"(
contract C {
- function f() {
+ function f() public {
ecrecover.value();
}
}
@@ -6531,7 +6542,7 @@ BOOST_AUTO_TEST_CASE(library_function_without_implementation)
{
char const* text = R"(
library L {
- function f();
+ function f() public;
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
@@ -6606,7 +6617,7 @@ BOOST_AUTO_TEST_CASE(reject_interface_creation)
char const* text = R"(
interface I {}
contract C {
- function f() {
+ function f() public {
new I();
}
}
@@ -6619,7 +6630,7 @@ BOOST_AUTO_TEST_CASE(accept_library_creation)
char const* text = R"(
library L {}
contract C {
- function f() {
+ function f() public {
new L();
}
}
@@ -6640,7 +6651,7 @@ BOOST_AUTO_TEST_CASE(tight_packing_literals)
{
char const* text = R"(
contract C {
- function f() pure returns (bytes32) {
+ function f() pure public returns (bytes32) {
return keccak256(1);
}
}
@@ -6648,7 +6659,7 @@ BOOST_AUTO_TEST_CASE(tight_packing_literals)
CHECK_WARNING(text, "The type of \"int_const 1\" was inferred as uint8.");
text = R"(
contract C {
- function f() pure returns (bytes32) {
+ function f() pure public returns (bytes32) {
return keccak256(uint8(1));
}
}
@@ -6656,7 +6667,7 @@ BOOST_AUTO_TEST_CASE(tight_packing_literals)
CHECK_SUCCESS_NO_WARNINGS(text);
text = R"(
contract C {
- function f() pure returns (bytes32) {
+ function f() pure public returns (bytes32) {
return sha3(1);
}
}
@@ -6664,7 +6675,7 @@ BOOST_AUTO_TEST_CASE(tight_packing_literals)
CHECK_WARNING(text, "The type of \"int_const 1\" was inferred as uint8.");
text = R"(
contract C {
- function f() pure returns (bytes32) {
+ function f() pure public returns (bytes32) {
return sha256(1);
}
}
@@ -6672,7 +6683,7 @@ BOOST_AUTO_TEST_CASE(tight_packing_literals)
CHECK_WARNING(text, "The type of \"int_const 1\" was inferred as uint8.");
text = R"(
contract C {
- function f() pure returns (bytes32) {
+ function f() pure public returns (bytes32) {
return ripemd160(1);
}
}