Suggest the experimental ABI encoder if using structs as function parameters

This commit is contained in:
Alex Beregszaszi 2017-12-02 01:01:55 +00:00
parent 226bfe5be1
commit e9d256ddf4
2 changed files with 12 additions and 0 deletions

View File

@ -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)

View File

@ -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);
}