mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Turn non-constant constants error into warning.
This commit is contained in:
parent
c65d506811
commit
9f328ff749
@ -17,7 +17,7 @@ Bugfixes:
|
|||||||
* Type system: Detect cyclic dependencies between constants.
|
* Type system: Detect cyclic dependencies between constants.
|
||||||
* Type system: Disallow arrays with negative length.
|
* Type system: Disallow arrays with negative length.
|
||||||
* Type system: Fix a crash related to invalid binary operators.
|
* Type system: Fix a crash related to invalid binary operators.
|
||||||
* Type system: Only allow compile-time constants for constant state variables.
|
* Type system: Warn if constant state variables are not compile-time constants.
|
||||||
* Type system: Disallow ``var`` declaration with empty tuple type.
|
* Type system: Disallow ``var`` declaration with empty tuple type.
|
||||||
* Type system: Correctly convert function argument types to pointers for member functions.
|
* Type system: Correctly convert function argument types to pointers for member functions.
|
||||||
* Type system: Move privateness of constructor into AST itself.
|
* Type system: Move privateness of constructor into AST itself.
|
||||||
|
@ -484,9 +484,10 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
|
|||||||
if (!_variable.value())
|
if (!_variable.value())
|
||||||
typeError(_variable.location(), "Uninitialized \"constant\" variable.");
|
typeError(_variable.location(), "Uninitialized \"constant\" variable.");
|
||||||
else if (!_variable.value()->annotation().isPure)
|
else if (!_variable.value()->annotation().isPure)
|
||||||
typeError(
|
warning(
|
||||||
_variable.value()->location(),
|
_variable.value()->location(),
|
||||||
"Initial value for constant variable has to be compile-time constant. "
|
"Initial value for constant variable has to be compile-time constant. "
|
||||||
|
"This will fail to compile with the next breaking version change."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!_variable.isStateVariable())
|
if (!_variable.isStateVariable())
|
||||||
|
@ -2180,7 +2180,8 @@ BOOST_AUTO_TEST_CASE(assigning_state_to_const_variable)
|
|||||||
address constant x = msg.sender;
|
address constant x = msg.sender;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_ERROR(text, TypeError, "Initial value for constant variable has to be compile-time constant.");
|
// Change to TypeError for 0.5.0.
|
||||||
|
CHECK_WARNING(text, "Initial value for constant variable has to be compile-time constant.");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(constant_string_literal_disallows_assignment)
|
BOOST_AUTO_TEST_CASE(constant_string_literal_disallows_assignment)
|
||||||
@ -2207,7 +2208,8 @@ BOOST_AUTO_TEST_CASE(assign_constant_function_value_to_constant)
|
|||||||
uint constant y = x();
|
uint constant y = x();
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_ERROR(text, TypeError, "Initial value for constant variable has to be compile-time constant.");
|
// Change to TypeError for 0.5.0.
|
||||||
|
CHECK_WARNING(text, "Initial value for constant variable has to be compile-time constant.");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(assignment_to_const_var_involving_conversion)
|
BOOST_AUTO_TEST_CASE(assignment_to_const_var_involving_conversion)
|
||||||
|
Loading…
Reference in New Issue
Block a user