solidity/test/libsolidity/syntaxTests/controlFlow/localStorageVariables/short_circuit_declaration_err.sol

25 lines
891 B
Solidity

contract C {
struct S { bool f; }
S s;
function f() internal view {
S storage c;
false && (c = s).f;
c;
}
function g() internal view {
S storage c;
true || (c = s).f;
c;
}
function h() internal view {
S storage c;
// expect error, although this is always fine
true && (false || (c = s).f);
c;
}
}
// ----
// TypeError 3464: (137-138): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError 3464: (235-236): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError 3464: (398-399): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.