mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Display location of invalid UTF-8 sequence in unicode literals in SyntaxChecker
This commit is contained in:
parent
ca743191b7
commit
0e5abbd4a9
@ -12,6 +12,7 @@ Compiler Features:
|
|||||||
* SMTChecker: Support structs.
|
* SMTChecker: Support structs.
|
||||||
* SMTChecker: Support ``type(T).min``, ``type(T).max``, and ``type(I).interfaceId``.
|
* SMTChecker: Support ``type(T).min``, ``type(T).max``, and ``type(I).interfaceId``.
|
||||||
* SMTChecker: Support ``address`` type conversion with literals, e.g. ``address(0)``.
|
* SMTChecker: Support ``address`` type conversion with literals, e.g. ``address(0)``.
|
||||||
|
* Type Checker: Report position of first invalid UTF-8 sequence in ``unicode""`` literals.
|
||||||
* Type Checker: More detailed error messages why implicit conversions fail.
|
* Type Checker: More detailed error messages why implicit conversions fail.
|
||||||
* Type Checker: Explain why oversized hex string literals can not be explicitly converted to a shorter ``bytesNN`` type.
|
* Type Checker: Explain why oversized hex string literals can not be explicitly converted to a shorter ``bytesNN`` type.
|
||||||
* Yul Optimizer: Prune unused parameters in functions.
|
* Yul Optimizer: Prune unused parameters in functions.
|
||||||
|
@ -219,11 +219,12 @@ bool SyntaxChecker::visit(Throw const& _throwStatement)
|
|||||||
|
|
||||||
bool SyntaxChecker::visit(Literal const& _literal)
|
bool SyntaxChecker::visit(Literal const& _literal)
|
||||||
{
|
{
|
||||||
if ((_literal.token() == Token::UnicodeStringLiteral) && !validateUTF8(_literal.value()))
|
size_t invalidSequence;
|
||||||
|
if ((_literal.token() == Token::UnicodeStringLiteral) && !validateUTF8(_literal.value(), invalidSequence))
|
||||||
m_errorReporter.syntaxError(
|
m_errorReporter.syntaxError(
|
||||||
8452_error,
|
8452_error,
|
||||||
_literal.location(),
|
_literal.location(),
|
||||||
"Invalid UTF-8 sequence found"
|
"Contains invalid UTF-8 sequence at position " + toString(invalidSequence) + "."
|
||||||
);
|
);
|
||||||
|
|
||||||
if (_literal.token() != Token::Number)
|
if (_literal.token() != Token::Number)
|
||||||
|
@ -2,5 +2,5 @@ contract C {
|
|||||||
string s = unicode"À";
|
string s = unicode"À";
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// SyntaxError 8452: (28-38): Invalid UTF-8 sequence found
|
// SyntaxError 8452: (28-38): Contains invalid UTF-8 sequence at position 0.
|
||||||
// TypeError 7407: (28-38): Type literal_string (contains invalid UTF-8 sequence at position 0) is not implicitly convertible to expected type string storage ref.
|
// TypeError 7407: (28-38): Type literal_string (contains invalid UTF-8 sequence at position 0) is not implicitly convertible to expected type string storage ref.
|
||||||
|
Loading…
Reference in New Issue
Block a user