Skip to content

Commit

Permalink
Fix address literals not being treated as compile-time constants
Browse files Browse the repository at this point in the history
The early return implemented for address literals in TypeChecker was
preventing the isPure annotation from getting applied. Closes ethereum#2441
  • Loading branch information
federicobond authored and chriseth committed Jun 23, 2017
1 parent b86a4ca commit 0fb1621
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Features:
* Code Generator: Added the Whiskers template system.

Bugfixes:
* Type Checker: Fix address literals not being treated as compile-time constants.
* Type Checker: Make UTF8-validation a bit more sloppy to include more valid sequences.
* Fixed crash concerning non-callable types.
* Unused variable warnings no longer issued for variables used inside inline assembly.
Expand Down
10 changes: 5 additions & 5 deletions libsolidity/analysis/TypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,21 +1726,21 @@ void TypeChecker::endVisit(Literal const& _literal)
if (_literal.looksLikeAddress())
{
if (_literal.passesAddressChecksum())
{
_literal.annotation().type = make_shared<IntegerType>(0, IntegerType::Modifier::Address);
return;
}
else
m_errorReporter.warning(
_literal.location(),
"This looks like an address but has an invalid checksum. "
"If this is not used as an address, please prepend '00'."
);
}
_literal.annotation().type = Type::forLiteral(_literal);
_literal.annotation().isPure = true;
if (!_literal.annotation().type)
_literal.annotation().type = Type::forLiteral(_literal);

if (!_literal.annotation().type)
m_errorReporter.fatalTypeError(_literal.location(), "Invalid literal value.");

_literal.annotation().isPure = true;
}

bool TypeChecker::contractDependenciesAreCyclic(
Expand Down

0 comments on commit 0fb1621

Please sign in to comment.