aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-08-02 18:26:43 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-08-04 21:03:37 +0800
commit494dea262e7d671ccd0f98b2df1c99fd86097adc (patch)
treed577fba5edef77ad2225ba456a090241dca02760
parentc835bcec623d6b6166add70456f5b6bee5c90572 (diff)
downloaddexon-solidity-494dea262e7d671ccd0f98b2df1c99fd86097adc.tar
dexon-solidity-494dea262e7d671ccd0f98b2df1c99fd86097adc.tar.gz
dexon-solidity-494dea262e7d671ccd0f98b2df1c99fd86097adc.tar.bz2
dexon-solidity-494dea262e7d671ccd0f98b2df1c99fd86097adc.tar.lz
dexon-solidity-494dea262e7d671ccd0f98b2df1c99fd86097adc.tar.xz
dexon-solidity-494dea262e7d671ccd0f98b2df1c99fd86097adc.tar.zst
dexon-solidity-494dea262e7d671ccd0f98b2df1c99fd86097adc.zip
Show unimplemented function if trying to instantiate an abstract class
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/analysis/TypeChecker.cpp9
-rw-r--r--libsolidity/interface/ErrorReporter.cpp10
-rw-r--r--libsolidity/interface/ErrorReporter.h6
4 files changed, 25 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md
index 86cf1058..a96485f9 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,6 +1,7 @@
### 0.4.15 (unreleased)
Features:
+ * Type Checker: Show unimplemented function if trying to instantiate an abstract class.
Bugfixes:
* Code Generator: ``.delegatecall()`` should always return execution outcome.
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index fab410eb..cc2f95ef 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1523,7 +1523,14 @@ void TypeChecker::endVisit(NewExpression const& _newExpression)
if (!contract)
m_errorReporter.fatalTypeError(_newExpression.location(), "Identifier is not a contract.");
if (!contract->annotation().unimplementedFunctions.empty())
- m_errorReporter.typeError(_newExpression.location(), "Trying to create an instance of an abstract contract.");
+ m_errorReporter.typeError(
+ _newExpression.location(),
+ SecondarySourceLocation().append(
+ "Missing implementation:",
+ contract->annotation().unimplementedFunctions.front()->location()
+ ),
+ "Trying to create an instance of an abstract contract."
+ );
if (!contract->constructorIsPublic())
m_errorReporter.typeError(_newExpression.location(), "Contract with internal constructor cannot be created directly.");
diff --git a/libsolidity/interface/ErrorReporter.cpp b/libsolidity/interface/ErrorReporter.cpp
index f9ef4ceb..e6171756 100644
--- a/libsolidity/interface/ErrorReporter.cpp
+++ b/libsolidity/interface/ErrorReporter.cpp
@@ -151,6 +151,16 @@ void ErrorReporter::syntaxError(SourceLocation const& _location, string const& _
);
}
+void ErrorReporter::typeError(SourceLocation const& _location, SecondarySourceLocation const& _secondaryLocation, string const& _description)
+{
+ error(
+ Error::Type::TypeError,
+ _location,
+ _secondaryLocation,
+ _description
+ );
+}
+
void ErrorReporter::typeError(SourceLocation const& _location, string const& _description)
{
error(
diff --git a/libsolidity/interface/ErrorReporter.h b/libsolidity/interface/ErrorReporter.h
index 8b066a3e..42b0c8b6 100644
--- a/libsolidity/interface/ErrorReporter.h
+++ b/libsolidity/interface/ErrorReporter.h
@@ -73,6 +73,12 @@ public:
void syntaxError(SourceLocation const& _location, std::string const& _description);
+ void typeError(
+ SourceLocation const& _location,
+ SecondarySourceLocation const& _secondaryLocation,
+ std::string const& _description
+ );
+
void typeError(SourceLocation const& _location, std::string const& _description);
void fatalTypeError(SourceLocation const& _location, std::string const& _description);