mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Support .offset and .length for calldata bytes and string arrays.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f(uint[] calldata bytesAsCalldata) external {
|
||||
assembly {
|
||||
let x := bytesAsCalldata
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1397: (112-127): Call data elements cannot be accessed directly. Use ".offset" and ".length" to access the calldata offset and length of this array and then use "calldatacopy".
|
||||
@@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
function f(uint[] calldata bytesAsCalldata) external pure {
|
||||
assembly {
|
||||
let x := bytesAsCalldata.offset
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f(bytes calldata bytesAsCalldata) external {
|
||||
assembly {
|
||||
let x := bytesAsCalldata.slot
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1536: (111-131): Calldata variables only support ".offset" and ".length".
|
||||
@@ -6,4 +6,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 2370: (111-126): Call data elements cannot be accessed directly. Copy to a local variable first or use "calldataload" or "calldatacopy" with manually determined offsets and sizes.
|
||||
// TypeError 1397: (111-126): Call data elements cannot be accessed directly. Use ".offset" and ".length" to access the calldata offset and length of this array and then use "calldatacopy".
|
||||
|
||||
@@ -7,4 +7,4 @@ contract test {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1408: (89-90): Only local variables are supported. To access storage variables, use the .slot and .offset suffixes.
|
||||
// TypeError 1408: (89-90): Only local variables are supported. To access storage variables, use the ".slot" and ".offset" suffixes.
|
||||
|
||||
+1
-1
@@ -10,4 +10,4 @@ contract test {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1408: (80-81): Only local variables are supported. To access storage variables, use the .slot and .offset suffixes.
|
||||
// TypeError 1408: (80-81): Only local variables are supported. To access storage variables, use the ".slot" and ".offset" suffixes.
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
contract test {
|
||||
uint x = 1;
|
||||
function f() public {
|
||||
assembly {
|
||||
let t := x.length
|
||||
x.length := 2
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 4656: (98-106): State variables only support ".slot" and ".offset".
|
||||
// TypeError 4656: (119-127): State variables only support ".slot" and ".offset".
|
||||
@@ -5,4 +5,4 @@ contract c {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1408: (75-76): Only local variables are supported. To access storage variables, use the .slot and .offset suffixes.
|
||||
// TypeError 1408: (75-76): Only local variables are supported. To access storage variables, use the ".slot" and ".offset" suffixes.
|
||||
|
||||
@@ -8,4 +8,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9068: (118-119): You have to use the .slot or .offset suffix to access storage reference variables.
|
||||
// TypeError 9068: (118-119): You have to use the ".slot" or ".offset" suffix to access storage reference variables.
|
||||
|
||||
@@ -9,5 +9,5 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 9467: (118-124): Identifier not found. Use ``.slot`` and ``.offset`` to access storage variables.
|
||||
// DeclarationError 9467: (142-150): Identifier not found. Use ``.slot`` and ``.offset`` to access storage variables.
|
||||
// DeclarationError 9467: (118-124): Identifier not found. Use ".slot" and ".offset" to access storage variables.
|
||||
// DeclarationError 9467: (142-150): Identifier not found. Use ".slot" and ".offset" to access storage variables.
|
||||
|
||||
@@ -6,4 +6,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 7944: (84-90): The suffixes .offset and .slot can only be used on storage variables.
|
||||
// TypeError 7944: (84-90): The suffixes ".offset", ".slot" and ".length" can only be used with variables.
|
||||
|
||||
@@ -9,5 +9,5 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 3622: (117-123): The suffixes .offset and .slot can only be used on storage variables.
|
||||
// TypeError 3622: (141-149): The suffixes .offset and .slot can only be used on storage variables.
|
||||
// TypeError 3622: (117-123): The suffix ".slot" is not supported by this variable or type.
|
||||
// TypeError 3622: (141-149): The suffix ".offset" is not supported by this variable or type.
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function f() pure external {
|
||||
function() external two_stack_slots;
|
||||
assembly {
|
||||
let x := two_stack_slots
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9857: (132-147): Only types that use one stack slot are supported.
|
||||
Reference in New Issue
Block a user