From e9d256ddf4322050f9b834abd3400f1cb5377f68 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Sat, 2 Dec 2017 01:01:55 +0000 Subject: [PATCH] Suggest the experimental ABI encoder if using structs as function parameters --- Changelog.md | 2 ++ libsolidity/analysis/TypeChecker.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/Changelog.md b/Changelog.md index 248165bbc..cf6498a16 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,8 @@ Features: * Inline Assembly: Issue warning for using jump labels (already existed for jump instructions). Bugfixes: + * Type Checker: Suggest the experimental ABI encoder if using ``struct``s as function parameters + (instead of an internal compiler error). ### 0.4.19 (2017-11-30) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 96160a751..daa5471ad 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -570,6 +570,16 @@ bool TypeChecker::visit(FunctionDefinition const& _function) m_errorReporter.typeError(var->location(), "Type is required to live outside storage."); if (_function.visibility() >= FunctionDefinition::Visibility::Public && !(type(*var)->interfaceType(isLibraryFunction))) m_errorReporter.fatalTypeError(var->location(), "Internal or recursive type is not allowed for public or external functions."); + if ( + _function.visibility() > FunctionDefinition::Visibility::Internal && + type(*var)->category() == Type::Category::Struct && + !_function.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2) + ) + m_errorReporter.typeError( + var->location(), + "Structs are only supported in the new experimental ABI encoder. " + "Use \"pragma experimental ABIEncoderV2;\" to enable the feature." + ); var->accept(*this); }