diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-08-08 22:55:41 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-08-08 22:59:24 +0800 |
commit | 3c791d637d6bdf709ec272e6c8cf9ff51abd34ef (patch) | |
tree | a2464e62ca686131e732bf04fbc2fed81c94cb38 | |
parent | 863778fe3614f8387723572693f276f66321fd74 (diff) | |
download | dexon-solidity-3c791d637d6bdf709ec272e6c8cf9ff51abd34ef.tar dexon-solidity-3c791d637d6bdf709ec272e6c8cf9ff51abd34ef.tar.gz dexon-solidity-3c791d637d6bdf709ec272e6c8cf9ff51abd34ef.tar.bz2 dexon-solidity-3c791d637d6bdf709ec272e6c8cf9ff51abd34ef.tar.lz dexon-solidity-3c791d637d6bdf709ec272e6c8cf9ff51abd34ef.tar.xz dexon-solidity-3c791d637d6bdf709ec272e6c8cf9ff51abd34ef.tar.zst dexon-solidity-3c791d637d6bdf709ec272e6c8cf9ff51abd34ef.zip |
Provide nicer error message when referencing overloaded references
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | libsolidity/analysis/ReferencesResolver.cpp | 3 | ||||
-rw-r--r-- | test/libsolidity/syntaxTests/inlineAssembly/overloaded_reference.sol | 11 |
3 files changed, 15 insertions, 0 deletions
diff --git a/Changelog.md b/Changelog.md index 2309edc3..37dcea7a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -73,6 +73,7 @@ Language Features: Compiler Features: * C API (``libsolc``): Export the ``solidity_license``, ``solidity_version`` and ``solidity_compile`` methods. + * Type Checker: Nicer error message when trying to reference overloaded identifiers in inline assembly. * Type Checker: Show named argument in case of error. * Tests: Determine transaction status during IPC calls. * Code Generator: Allocate and free local variables according to their scope. diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 501521f5..2cf09eff 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -264,7 +264,10 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly) declarations = m_resolver.nameFromCurrentScope(realName); } if (declarations.size() != 1) + { + declarationError(_identifier.location, "Multiple matching identifiers. Resolving overloaded identifiers is not supported."); return size_t(-1); + } if (auto var = dynamic_cast<VariableDeclaration const*>(declarations.front())) if (var->isLocalVariable() && _crossesFunctionBoundary) { diff --git a/test/libsolidity/syntaxTests/inlineAssembly/overloaded_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/overloaded_reference.sol new file mode 100644 index 00000000..d1bcc946 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/overloaded_reference.sol @@ -0,0 +1,11 @@ +contract C { + function f() pure public {} + function f(address) pure public {} + function g() pure public { + assembly { + let x := f + } + } +} +// ---- +// DeclarationError: (155-156): Multiple matching identifiers. Resolving overloaded identifiers is not supported. |