Consistent terminology for attached/bound functions

This commit is contained in:
wechman
2022-12-07 19:31:41 +01:00
committed by Kamil Śliwak
parent 1c8745c54a
commit 64a4f32bc2
42 changed files with 132 additions and 133 deletions
+1 -1
View File
@@ -2811,7 +2811,7 @@ BOOST_AUTO_TEST_CASE(return_external_function_type)
);
}
// TODO: store bound internal library functions
// TODO: store attached internal library functions
BOOST_AUTO_TEST_CASE(shift_bytes)
{
@@ -29,7 +29,7 @@ import {C} from "B";
contract D {
function test() public returns (uint) {
C c = new C();
// This tests that bound functions are available
// This tests that attached functions are available
// even if the type is not available by name.
// This is a regular function call, a
// public and an internal library call
@@ -22,4 +22,4 @@ contract Test {
}
}
// ----
// TypeError 9574: (B:269-313): Type function (struct L.Item memory) is not implicitly convertible to expected type function (struct L.Item memory) external. Special functions can not be converted to function types.
// TypeError 9574: (B:269-313): Type function (struct L.Item memory) is not implicitly convertible to expected type function (struct L.Item memory) external. Special functions cannot be converted to function types.
@@ -53,7 +53,7 @@ contract C {
// TypeError 9553: (415-428): Invalid type for argument in function call. Invalid implicit conversion from function () view external returns (uint256) to function () pure external returns (uint256) requested.
// TypeError 9553: (465-481): Invalid type for argument in function call. Invalid implicit conversion from function () external returns (uint256) to function () pure external returns (uint256) requested.
// TypeError 9553: (518-545): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) pure external returns (uint256) to function () pure external returns (uint256) requested.
// TypeError 9553: (582-589): Invalid type for argument in function call. Invalid implicit conversion from function () view returns (uint256) to function () pure external returns (uint256) requested. Special functions can not be converted to function types.
// TypeError 9553: (626-629): Invalid type for argument in function call. Invalid implicit conversion from function () pure returns (uint256) to function () pure external returns (uint256) requested. Special functions can not be converted to function types.
// TypeError 9553: (666-686): Invalid type for argument in function call. Invalid implicit conversion from function () pure returns (uint256) to function () pure external returns (uint256) requested. Special functions can not be converted to function types.
// TypeError 9553: (582-589): Invalid type for argument in function call. Invalid implicit conversion from function () view returns (uint256) to function () pure external returns (uint256) requested. Special functions cannot be converted to function types.
// TypeError 9553: (626-629): Invalid type for argument in function call. Invalid implicit conversion from function () pure returns (uint256) to function () pure external returns (uint256) requested. Special functions cannot be converted to function types.
// TypeError 9553: (666-686): Invalid type for argument in function call. Invalid implicit conversion from function () pure returns (uint256) to function () pure external returns (uint256) requested. Special functions cannot be converted to function types.
// TypeError 9582: (723-748): Member "testInternalFunction" not found or not visible after argument-dependent lookup in contract C.
@@ -4,4 +4,4 @@ contract C {
function() internal pure x = E;
}
// ----
// TypeError 7407: (58-59): Type error E() is not implicitly convertible to expected type function () pure. Special functions can not be converted to function types.
// TypeError 7407: (58-59): Type error E() is not implicitly convertible to expected type function () pure. Special functions cannot be converted to function types.
@@ -30,6 +30,6 @@ contract E {
}
}
// ----
// TypeError 9553: (140-143): Invalid type for argument in function call. Invalid implicit conversion from function () to function () external requested. Special functions can not be converted to function types.
// TypeError 9553: (230-233): Invalid type for argument in function call. Invalid implicit conversion from function () to function () external requested. Special functions can not be converted to function types.
// TypeError 9553: (345-348): Invalid type for argument in function call. Invalid implicit conversion from function D.f() to function () external requested. Special functions can not be converted to function types.
// TypeError 9553: (140-143): Invalid type for argument in function call. Invalid implicit conversion from function () to function () external requested. Special functions cannot be converted to function types.
// TypeError 9553: (230-233): Invalid type for argument in function call. Invalid implicit conversion from function () to function () external requested. Special functions cannot be converted to function types.
// TypeError 9553: (345-348): Invalid type for argument in function call. Invalid implicit conversion from function D.f() to function () external requested. Special functions cannot be converted to function types.
@@ -4,4 +4,4 @@ contract C {
function() internal pure x = E;
}
// ----
// TypeError 7407: (66-67): Type event E(uint256) is not implicitly convertible to expected type function () pure. Special functions can not be converted to function types.
// TypeError 7407: (66-67): Type event E(uint256) is not implicitly convertible to expected type function () pure. Special functions cannot be converted to function types.
@@ -12,4 +12,4 @@ contract C {
}
}
// ----
// TypeError 9574: (209-280): Type function (uint256,uint256) pure returns (uint256) is not implicitly convertible to expected type function (uint256,uint256) pure returns (uint256). Bound functions can not be converted to non-bound functions.
// TypeError 9574: (209-280): Type function (uint256,uint256) pure returns (uint256) is not implicitly convertible to expected type function (uint256,uint256) pure returns (uint256). Attached functions cannot be converted into unattached functions.
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
// TypeError 9574: (42-103): Type function (uint256) view returns (bytes32) is not implicitly convertible to expected type function (uint256) view returns (bytes32). Special functions can not be converted to function types.
// TypeError 9574: (42-103): Type function (uint256) view returns (bytes32) is not implicitly convertible to expected type function (uint256) view returns (bytes32). Special functions cannot be converted to function types.
@@ -10,5 +10,5 @@ contract C {
}
}
// ----
// TypeError 9553: (230-233): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) returns (uint256) to function (uint256) external returns (uint256) requested. Special functions can not be converted to function types.
// TypeError 9574: (244-305): Type function (uint256) returns (uint256) is not implicitly convertible to expected type function (uint256) external returns (uint256). Special functions can not be converted to function types.
// TypeError 9553: (230-233): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) returns (uint256) to function (uint256) external returns (uint256) requested. Special functions cannot be converted to function types.
// TypeError 9574: (244-305): Type function (uint256) returns (uint256) is not implicitly convertible to expected type function (uint256) external returns (uint256). Special functions cannot be converted to function types.
@@ -3,4 +3,4 @@ contract test {
function(bytes memory) external internal a = fa;
}
// ----
// TypeError 7407: (106-108): Type function (bytes memory) is not implicitly convertible to expected type function (bytes memory) external. Special functions can not be converted to function types.
// TypeError 7407: (106-108): Type function (bytes memory) is not implicitly convertible to expected type function (bytes memory) external. Special functions cannot be converted to function types.
@@ -2,10 +2,10 @@ library D { function double(uint self) public returns (uint) { return 2; } }
contract C {
using D for uint;
function f(uint16 a) public returns (uint) {
// This is an error because the function is only bound to uint.
// Had it been bound to *, it would have worked.
// This is an error because the function is only attached to uint.
// Had it been attached to *, it would have worked.
return a.double();
}
}
// ----
// TypeError 9582: (305-313): Member "double" not found or not visible after argument-dependent lookup in uint16.
// TypeError 9582: (311-319): Member "double" not found or not visible after argument-dependent lookup in uint16.
@@ -2,9 +2,9 @@ library D { function double(bytes32 self) public returns (uint) { return 2; } }
contract C {
using D for *;
function f(uint a) public returns (uint) {
// Bound to a, but self type does not match.
// Attached to a, but self type does not match.
return a.double();
}
}
// ----
// TypeError 9582: (227-235): Member "double" not found or not visible after argument-dependent lookup in uint256.
// TypeError 9582: (230-238): Member "double" not found or not visible after argument-dependent lookup in uint256.
@@ -9,5 +9,5 @@ contract C {
}
}
// ----
// TypeError 9574: (218-271): Type function (struct D.s storage pointer,uint256) returns (uint256) is not implicitly convertible to expected type function (struct D.s storage pointer,uint256) returns (uint256). Bound functions can not be converted to non-bound functions.
// TypeError 9574: (218-271): Type function (struct D.s storage pointer,uint256) returns (uint256) is not implicitly convertible to expected type function (struct D.s storage pointer,uint256) returns (uint256). Attached functions cannot be converted into unattached functions.
// TypeError 6160: (298-302): Wrong argument count for function call: 1 arguments given but expected 2.
@@ -43,7 +43,7 @@ contract C is Base {
abi.encodeCall(L.fInternal, (1, "123"));
abi.encodeCall(L.fExternal, (1, "123"));
}
function failBoundLibraryPointerCall() public returns (bytes memory) {
function failAttachedLibraryPointerCall() public returns (bytes memory) {
uint256 x = 1;
return abi.encodeCall(x.fExternal, (1, "123"));
}
@@ -70,9 +70,9 @@ contract C is Base {
// TypeError 3509: (1187-1207): Expected regular external function type, or external view on public function. Provided internal function.
// TypeError 3509: (1286-1297): Expected regular external function type, or external view on public function. Provided internal function.
// TypeError 3509: (1329-1340): Expected regular external function type, or external view on public function. Cannot use library functions for abi.encodeCall.
// TypeError 3509: (1471-1482): Expected regular external function type, or external view on public function. Cannot use library functions for abi.encodeCall.
// TypeError 3509: (1592-1601): Expected regular external function type, or external view on public function. Provided internal function. Did you forget to prefix "this."?
// TypeError 3509: (1722-1745): Expected regular external function type, or external view on public function. Provided internal function. Functions from base contracts have to be external.
// TypeError 3509: (1771-1796): Expected regular external function type, or external view on public function. Provided internal function. Functions from base contracts have to be external.
// TypeError 3509: (1902-1911): Expected regular external function type, or external view on public function. Provided internal function.
// TypeError 3509: (2010-2019): Expected regular external function type, or external view on public function. Provided creation function.
// TypeError 3509: (1474-1485): Expected regular external function type, or external view on public function. Cannot use library functions for abi.encodeCall.
// TypeError 3509: (1595-1604): Expected regular external function type, or external view on public function. Provided internal function. Did you forget to prefix "this."?
// TypeError 3509: (1725-1748): Expected regular external function type, or external view on public function. Provided internal function. Functions from base contracts have to be external.
// TypeError 3509: (1774-1799): Expected regular external function type, or external view on public function. Provided internal function. Functions from base contracts have to be external.
// TypeError 3509: (1905-1914): Expected regular external function type, or external view on public function. Provided internal function.
// TypeError 3509: (2013-2022): Expected regular external function type, or external view on public function. Provided creation function.
@@ -10,5 +10,5 @@ contract B is A {
}
}
// ----
// TypeError 9574: (133-160): Type function A.f() is not implicitly convertible to expected type function () external. Special functions can not be converted to function types.
// TypeError 9574: (170-202): Type function A.g() pure is not implicitly convertible to expected type function () pure external. Special functions can not be converted to function types.
// TypeError 9574: (133-160): Type function A.f() is not implicitly convertible to expected type function () external. Special functions cannot be converted to function types.
// TypeError 9574: (170-202): Type function A.g() pure is not implicitly convertible to expected type function () pure external. Special functions cannot be converted to function types.
@@ -10,5 +10,5 @@ contract B {
}
}
// ----
// TypeError 9574: (128-155): Type function A.f() is not implicitly convertible to expected type function () external. Special functions can not be converted to function types.
// TypeError 9574: (165-197): Type function A.g() pure is not implicitly convertible to expected type function () pure external. Special functions can not be converted to function types.
// TypeError 9574: (128-155): Type function A.f() is not implicitly convertible to expected type function () external. Special functions cannot be converted to function types.
// TypeError 9574: (165-197): Type function A.g() pure is not implicitly convertible to expected type function () pure external. Special functions cannot be converted to function types.
@@ -4,5 +4,5 @@ function test() pure {
function (int) returns (MyInt) g = MyInt.wrap;
}
// ----
// TypeError 9574: (46-93): Type function (MyInt) pure returns (int256) is not implicitly convertible to expected type function (MyInt) returns (int256). Special functions can not be converted to function types.
// TypeError 9574: (99-144): Type function (int256) pure returns (MyInt) is not implicitly convertible to expected type function (int256) returns (MyInt). Special functions can not be converted to function types.
// TypeError 9574: (46-93): Type function (MyInt) pure returns (int256) is not implicitly convertible to expected type function (MyInt) returns (int256). Special functions cannot be converted to function types.
// TypeError 9574: (99-144): Type function (int256) pure returns (MyInt) is not implicitly convertible to expected type function (int256) returns (MyInt). Special functions cannot be converted to function types.
@@ -10,5 +10,5 @@ contract C {
using {id} for S;
}
// ----
// TypeError 3100: (112-114): The function "id" cannot be bound to the type "uint256" because the type cannot be implicitly converted to the first argument of the function ("uint16").
// TypeError 3100: (140-142): The function "id" cannot be bound to the type "struct S" because the type cannot be implicitly converted to the first argument of the function ("uint16").
// TypeError 3100: (112-114): The function "id" cannot be attached to the type "uint256" because the type cannot be implicitly converted to the first argument of the function ("uint16").
// TypeError 3100: (140-142): The function "id" cannot be attached to the type "struct S" because the type cannot be implicitly converted to the first argument of the function ("uint16").
@@ -2,4 +2,4 @@ using {f} for * global;
function f(uint) pure{}
// ----
// SyntaxError 8118: (0-23): The type has to be specified explicitly at file level (cannot use '*').
// SyntaxError 2854: (0-23): Can only globally bind functions to specific types.
// SyntaxError 2854: (0-23): Can only globally attach functions to specific types.
@@ -2,4 +2,4 @@ using L for * global;
library L {}
// ----
// SyntaxError 8118: (0-21): The type has to be specified explicitly at file level (cannot use '*').
// SyntaxError 2854: (0-21): Can only globally bind functions to specific types.
// SyntaxError 2854: (0-21): Can only globally attach functions to specific types.
@@ -7,7 +7,7 @@ function f1(S memory _x) pure returns (uint) { return _x.x + 1; }
==== Source: B ====
contract C {
// Here, f points to f1, so we end up with two different functions
// bound as S.f
// attached as S.f
using {f} for S;
function test() pure public
@@ -18,4 +18,4 @@ contract C {
import {gen as g, f1 as f, S} from "A";
import "A" as A;
// ----
// TypeError 6675: (B:181-186): Member "f" not unique after argument-dependent lookup in struct S memory.
// TypeError 6675: (B:184-189): Member "f" not unique after argument-dependent lookup in struct S memory.
@@ -2,4 +2,4 @@ using {f} for * global;
function f(uint) pure{}
// ----
// SyntaxError 8118: (0-23): The type has to be specified explicitly at file level (cannot use '*').
// SyntaxError 2854: (0-23): Can only globally bind functions to specific types.
// SyntaxError 2854: (0-23): Can only globally attach functions to specific types.
@@ -4,4 +4,4 @@ function one() pure returns(uint) {
using {one} for uint;
// ----
// TypeError 4731: (60-63): The function "one" does not have any parameters, and therefore cannot be bound to the type "uint256".
// TypeError 4731: (60-63): The function "one" does not have any parameters, and therefore cannot be attached to the type "uint256".
@@ -2,4 +2,4 @@ struct S { uint8 x; }
function f() {}
using {f} for S;
// ----
// TypeError 4731: (45-46): The function "f" does not have any parameters, and therefore cannot be bound to the type "struct S".
// TypeError 4731: (45-46): The function "f" does not have any parameters, and therefore cannot be attached to the type "struct S".
@@ -5,5 +5,5 @@ contract C {
function g(uint) public { }
}
// ----
// TypeError 4167: (24-25): Only file-level functions and library functions can be bound to a type in a "using" statement
// TypeError 4167: (27-28): Only file-level functions and library functions can be bound to a type in a "using" statement
// TypeError 4167: (24-25): Only file-level functions and library functions can be attached to a type in a "using" statement
// TypeError 4167: (27-28): Only file-level functions and library functions can be attached to a type in a "using" statement