aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonardo Alt <leo@ethereum.org>2018-07-30 22:43:50 +0800
committerLeonardo Alt <leo@ethereum.org>2018-07-31 17:17:51 +0800
commit210fee571fb786751763e731f6fb107891e13383 (patch)
treee3d8f0c078bdebd6c5932a003cf3ba822c87239e
parentbc13365a7b3920c361ff2ae5f1a9bb7e98ad07b2 (diff)
downloaddexon-solidity-210fee571fb786751763e731f6fb107891e13383.tar
dexon-solidity-210fee571fb786751763e731f6fb107891e13383.tar.gz
dexon-solidity-210fee571fb786751763e731f6fb107891e13383.tar.bz2
dexon-solidity-210fee571fb786751763e731f6fb107891e13383.tar.lz
dexon-solidity-210fee571fb786751763e731f6fb107891e13383.tar.xz
dexon-solidity-210fee571fb786751763e731f6fb107891e13383.tar.zst
dexon-solidity-210fee571fb786751763e731f6fb107891e13383.zip
Fix crash when FunctionType has undeclared type as parameter
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/analysis/ReferencesResolver.cpp2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol7
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol5
9 files changed, 38 insertions, 12 deletions
diff --git a/Changelog.md b/Changelog.md
index 2953c86b..da287000 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -73,6 +73,7 @@ Bugfixes:
* Code Generator: Fix allocation of byte arrays (zeroed out too much memory).
* Fix NatSpec json output for `@notice` and `@dev` tags on contract definitions.
* References Resolver: Enforce ``storage`` as data location for mappings.
+ * References Resolver: Report error instead of assertion fail when FunctionType has an undeclared type as parameter.
* Type Checker: Consider fixed size arrays when checking for recursive structs.
* Type System: Allow arbitrary exponents for literals with a mantissa of zero.
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp
index 5815e3d2..a9a998b0 100644
--- a/libsolidity/analysis/ReferencesResolver.cpp
+++ b/libsolidity/analysis/ReferencesResolver.cpp
@@ -144,7 +144,7 @@ void ReferencesResolver::endVisit(UserDefinedTypeName const& _typeName)
Declaration const* declaration = m_resolver.pathFromCurrentScope(_typeName.namePath());
if (!declaration)
{
- declarationError(_typeName.location(), "Identifier not found or not unique.");
+ fatalDeclarationError(_typeName.location(), "Identifier not found or not unique.");
return;
}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol
deleted file mode 100644
index 1b6bbae7..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-contract test {
- function f() public {
- uintM something = 3;
- intM should = 4;
- bytesM fail = "now";
- }
-}
-// ----
-// DeclarationError: (50-55): Identifier not found or not unique.
-// DeclarationError: (79-83): Identifier not found or not unique.
-// DeclarationError: (104-110): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol
new file mode 100644
index 00000000..0d0a0797
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ uintM something = 3;
+ }
+}
+// ----
+// DeclarationError: (50-55): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol
new file mode 100644
index 00000000..b9590a8c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ intM should = 4;
+ }
+}
+// ----
+// DeclarationError: (50-54): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol
new file mode 100644
index 00000000..85d4c25b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol
@@ -0,0 +1,7 @@
+contract test {
+ function f() public {
+ bytesM fail = "now";
+ }
+}
+// ----
+// DeclarationError: (50-56): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol
new file mode 100644
index 00000000..962f4fe4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol
@@ -0,0 +1,5 @@
+contract C {
+ function a(function(Nested)) external pure {}
+}
+// ----
+// DeclarationError: (37-43): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol
new file mode 100644
index 00000000..735af9e9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol
@@ -0,0 +1,5 @@
+contract C {
+ function a(function(Nested) external) external pure {}
+}
+// ----
+// DeclarationError: (37-43): Identifier not found or not unique.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol
new file mode 100644
index 00000000..ffb467cd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol
@@ -0,0 +1,5 @@
+contract C {
+ function a(function(function(function(Nested)))) external pure {}
+}
+// ----
+// DeclarationError: (55-61): Identifier not found or not unique.