mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9646 from a3d4/improve-error-coverage-syntaxchecker
Improve error coverage of syntax checker
This commit is contained in:
commit
4a720a6511
@ -364,23 +364,6 @@ bool SyntaxChecker::visit(FunctionTypeName const& _node)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SyntaxChecker::visit(VariableDeclarationStatement const& _statement)
|
|
||||||
{
|
|
||||||
// Report if none of the variable components in the tuple have a name (only possible via deprecated "var")
|
|
||||||
if (std::all_of(
|
|
||||||
_statement.declarations().begin(),
|
|
||||||
_statement.declarations().end(),
|
|
||||||
[](ASTPointer<VariableDeclaration> const& declaration) { return declaration == nullptr; }
|
|
||||||
))
|
|
||||||
m_errorReporter.syntaxError(
|
|
||||||
3299_error,
|
|
||||||
_statement.location(),
|
|
||||||
"The use of the \"var\" keyword is disallowed. The declaration part of the statement can be removed, since it is empty."
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SyntaxChecker::visit(StructDefinition const& _struct)
|
bool SyntaxChecker::visit(StructDefinition const& _struct)
|
||||||
{
|
{
|
||||||
if (_struct.members().empty())
|
if (_struct.members().empty())
|
||||||
|
@ -87,8 +87,6 @@ private:
|
|||||||
bool visit(FunctionDefinition const& _function) override;
|
bool visit(FunctionDefinition const& _function) override;
|
||||||
bool visit(FunctionTypeName const& _node) override;
|
bool visit(FunctionTypeName const& _node) override;
|
||||||
|
|
||||||
bool visit(VariableDeclarationStatement const& _statement) override;
|
|
||||||
|
|
||||||
bool visit(StructDefinition const& _struct) override;
|
bool visit(StructDefinition const& _struct) override;
|
||||||
bool visit(Literal const& _literal) override;
|
bool visit(Literal const& _literal) override;
|
||||||
|
|
||||||
|
@ -12,8 +12,10 @@ SOURCE_FILE_PATTERN = r"\b\d+_error\b"
|
|||||||
|
|
||||||
def read_file(file_name):
|
def read_file(file_name):
|
||||||
content = None
|
content = None
|
||||||
|
_, tail = path.split(file_name)
|
||||||
|
is_latin = tail == "invalid_utf8_sequence.sol"
|
||||||
try:
|
try:
|
||||||
with open(file_name, "r", encoding=ENCODING) as f:
|
with open(file_name, "r", encoding="latin-1" if is_latin else ENCODING) as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
finally:
|
finally:
|
||||||
if content == None:
|
if content == None:
|
||||||
@ -219,12 +221,12 @@ def examine_id_coverage(top_dir, source_id_to_file_names, new_ids_only=False):
|
|||||||
old_source_only_ids = {
|
old_source_only_ids = {
|
||||||
"1054", "1123", "1133", "1220", "1584", "1823", "1950", "1957",
|
"1054", "1123", "1133", "1220", "1584", "1823", "1950", "1957",
|
||||||
"1988", "2418", "2461", "2512", "2592", "2657", "2800", "2842", "2856",
|
"1988", "2418", "2461", "2512", "2592", "2657", "2800", "2842", "2856",
|
||||||
"3263", "3299", "3356", "3441", "3682", "3876",
|
"3263", "3356", "3441", "3682", "3876",
|
||||||
"3893", "3997", "4010", "4802", "4805", "4828",
|
"3893", "3997", "4010", "4802", "4805", "4828",
|
||||||
"4904", "4990", "5052", "5073", "5170", "5188", "5272", "5333", "5347", "5473",
|
"4904", "4990", "5052", "5073", "5170", "5188", "5272", "5333", "5347", "5473",
|
||||||
"5622", "6041", "6052", "6272", "6708", "6792", "6931", "7110", "7128", "7186",
|
"5622", "6041", "6052", "6272", "6708", "6792", "6931", "7110", "7128", "7186",
|
||||||
"7319", "7589", "7593", "7653", "7812", "7885", "8065", "8084", "8140",
|
"7319", "7589", "7593", "7653", "7812", "7885", "8065", "8084", "8140",
|
||||||
"8261", "8312", "8452", "8592", "8758", "9011",
|
"8261", "8312", "8592", "8758", "9011",
|
||||||
"9085", "9390", "9440", "9547", "9551", "9615", "9980"
|
"9085", "9390", "9440", "9547", "9551", "9615", "9980"
|
||||||
}
|
}
|
||||||
new_source_only_ids = source_only_ids - old_source_only_ids
|
new_source_only_ids = source_only_ids - old_source_only_ids
|
||||||
|
@ -10,7 +10,7 @@ import sys
|
|||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
from os.path import join, isfile
|
from os.path import join, isfile, split
|
||||||
|
|
||||||
def extract_test_cases(path):
|
def extract_test_cases(path):
|
||||||
lines = open(path, encoding="utf8", errors='ignore', mode='r').read().splitlines()
|
lines = open(path, encoding="utf8", errors='ignore', mode='r').read().splitlines()
|
||||||
@ -99,5 +99,8 @@ if __name__ == '__main__':
|
|||||||
if 'compilationTests' in subdirs:
|
if 'compilationTests' in subdirs:
|
||||||
subdirs.remove('compilationTests')
|
subdirs.remove('compilationTests')
|
||||||
for f in files:
|
for f in files:
|
||||||
|
_, tail = split(f)
|
||||||
|
if tail == "invalid_utf8_sequence.sol":
|
||||||
|
continue # ignore the test with broken utf-8 encoding
|
||||||
path = join(root, f)
|
path = join(root, f)
|
||||||
extract_and_write(f, path)
|
extract_and_write(f, path)
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
contract C {
|
||||||
|
string s = unicode"À";
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// SyntaxError 8452: (28-38): Invalid UTF-8 sequence found
|
||||||
|
// 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