style fixes

This commit is contained in:
Daniel Kirchner 2023-08-22 17:56:26 +02:00 committed by Nikola Matic
parent 43ca0f0947
commit f7cbddb7d5
12 changed files with 126 additions and 127 deletions

View File

@ -307,8 +307,8 @@ namespace TokenTraits
constexpr bool isElementaryTypeName(Token tok) constexpr bool isElementaryTypeName(Token tok)
{ {
return (Token::Int <= tok && tok < Token::TypesEnd) || return (Token::Int <= tok && tok < Token::TypesEnd) ||
tok == Token::Word || tok == Token::Void || tok == Token::Integer || tok == Token::Word || tok == Token::Void || tok == Token::Integer ||
tok == Token::Pair || tok == Token::Unit || tok == Token::Fun; tok == Token::Pair || tok == Token::Unit || tok == Token::Fun;
} }
constexpr bool isAssignmentOp(Token tok) { return Token::Assign <= tok && tok <= Token::AssignMod; } constexpr bool isAssignmentOp(Token tok) { return Token::Assign <= tok && tok <= Token::AssignMod; }
constexpr bool isBinaryOp(Token op) { return Token::Comma <= op && op <= Token::Exp; } constexpr bool isBinaryOp(Token op) { return Token::Comma <= op && op <= Token::Exp; }
@ -344,7 +344,7 @@ namespace TokenTraits
constexpr bool isBuiltinTypeClassName(Token tok) constexpr bool isBuiltinTypeClassName(Token tok)
{ {
return tok == Token::Integer || (isBinaryOp(tok) && tok != Token::Comma) || return tok == Token::Integer || (isBinaryOp(tok) && tok != Token::Comma) ||
isCompareOp(tok) || isUnaryOp(tok) || (isAssignmentOp(tok) && tok != Token::Assign); isCompareOp(tok) || isUnaryOp(tok) || (isAssignmentOp(tok) && tok != Token::Assign);
} }
constexpr bool isExperimentalSolidityKeyword(Token tok) constexpr bool isExperimentalSolidityKeyword(Token tok)
{ {

View File

@ -304,7 +304,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier)
} }
std::string name = splitName.front(); std::string name = splitName.front();
auto declarations = m_resolver.nameFromCurrentScope(name); auto declarations = m_resolver.nameFromCurrentScope(name);
switch(declarations.size()) switch (declarations.size())
{ {
case 0: case 0:
if (splitName.size() > 1) if (splitName.size() > 1)

View File

@ -2511,11 +2511,11 @@ public:
ASTPointer<TypeClassName> _class, ASTPointer<TypeClassName> _class,
std::vector<ASTPointer<ASTNode>> _subNodes std::vector<ASTPointer<ASTNode>> _subNodes
): ):
ASTNode(_id, _location), ASTNode(_id, _location),
m_typeConstructor(std::move(_typeConstructor)), m_typeConstructor(std::move(_typeConstructor)),
m_argumentSorts(std::move(_argumentSorts)), m_argumentSorts(std::move(_argumentSorts)),
m_class(std::move(_class)), m_class(std::move(_class)),
m_subNodes(std::move(_subNodes)) m_subNodes(std::move(_subNodes))
{} {}
void accept(ASTVisitor& _visitor) override; void accept(ASTVisitor& _visitor) override;

View File

@ -1063,7 +1063,7 @@ void TypeClassInstantiation::accept(ASTVisitor& _visitor)
if (_visitor.visit(*this)) if (_visitor.visit(*this))
{ {
m_typeConstructor->accept(_visitor); m_typeConstructor->accept(_visitor);
if(m_argumentSorts) if (m_argumentSorts)
m_argumentSorts->accept(_visitor); m_argumentSorts->accept(_visitor);
m_class->accept(_visitor); m_class->accept(_visitor);
listAccept(m_subNodes, _visitor); listAccept(m_subNodes, _visitor);
@ -1076,7 +1076,7 @@ void TypeClassInstantiation::accept(ASTConstVisitor& _visitor) const
if (_visitor.visit(*this)) if (_visitor.visit(*this))
{ {
m_typeConstructor->accept(_visitor); m_typeConstructor->accept(_visitor);
if(m_argumentSorts) if (m_argumentSorts)
m_argumentSorts->accept(_visitor); m_argumentSorts->accept(_visitor);
m_class->accept(_visitor); m_class->accept(_visitor);
listAccept(m_subNodes, _visitor); listAccept(m_subNodes, _visitor);

View File

@ -128,20 +128,20 @@ bool Analysis::check(std::vector<std::shared_ptr<SourceUnit const>> const& _sour
return ([&](auto&& _step) { return ([&](auto&& _step) {
for (auto source: _sourceUnits) for (auto source: _sourceUnits)
if (!_step.analyze(*source)) if (!_step.analyze(*source))
return false; return false;
return true; return true;
}(std::tuple_element_t<decltype(_indexTuple)::value, AnalysisSteps>{*this}) && ...); }(std::tuple_element_t<decltype(_indexTuple)::value, AnalysisSteps>{*this}) && ...);
}, makeIndexTuple(std::make_index_sequence<std::tuple_size_v<AnalysisSteps>>{})); }, makeIndexTuple(std::make_index_sequence<std::tuple_size_v<AnalysisSteps>>{}));
/* /*
{ {
SyntaxRestrictor syntaxRestrictor{*this}; SyntaxRestrictor syntaxRestrictor{*this};
for (auto source: _sourceUnits) for (auto source: _sourceUnits)
if (!syntaxRestrictor.analyze(*source)) if (!syntaxRestrictor.analyze(*source))
return false; return false;
} }
{ {
TypeRegistration typeRegistration{*this}; TypeRegistration typeRegistration{*this};
for (auto source: _sourceUnits) for (auto source: _sourceUnits)
if (!typeRegistration.analyze(*source)) if (!typeRegistration.analyze(*source))

View File

@ -216,7 +216,7 @@ bool TypeInference::visit(TypeClassDefinition const& _typeClassDefinition)
if (!functionTypes.emplace(functionDefinition->name(), functionType).second) if (!functionTypes.emplace(functionDefinition->name(), functionType).second)
m_errorReporter.fatalTypeError(0000_error, functionDefinition->location(), "Function in type class declared multiple times."); m_errorReporter.fatalTypeError(0000_error, functionDefinition->location(), "Function in type class declared multiple times.");
auto typeVars = TypeEnvironmentHelpers{*m_env}.typeVars(functionType); auto typeVars = TypeEnvironmentHelpers{*m_env}.typeVars(functionType);
if(typeVars.size() != 1) if (typeVars.size() != 1)
m_errorReporter.fatalTypeError(0000_error, functionDefinition->location(), "Function in type class may only depend on the type class variable."); m_errorReporter.fatalTypeError(0000_error, functionDefinition->location(), "Function in type class may only depend on the type class variable.");
unify(typeVars.front(), typeVar, functionDefinition->location()); unify(typeVars.front(), typeVar, functionDefinition->location());
typeMembers[functionDefinition->name()] = TypeMember{functionType}; typeMembers[functionDefinition->name()] = TypeMember{functionType};
@ -499,7 +499,7 @@ void TypeInference::endVisit(Assignment const& _assignment)
experimental::Type TypeInference::handleIdentifierByReferencedDeclaration(langutil::SourceLocation _location, Declaration const& _declaration) experimental::Type TypeInference::handleIdentifierByReferencedDeclaration(langutil::SourceLocation _location, Declaration const& _declaration)
{ {
switch(m_expressionContext) switch (m_expressionContext)
{ {
case ExpressionContext::Term: case ExpressionContext::Term:
{ {
@ -601,7 +601,7 @@ bool TypeInference::visit(Identifier const& _identifier)
return false; return false;
} }
switch(m_expressionContext) switch (m_expressionContext)
{ {
case ExpressionContext::Term: case ExpressionContext::Term:
// TODO: error handling // TODO: error handling
@ -791,9 +791,7 @@ experimental::Type TypeInference::memberType(Type _type, std::string _memberName
{ {
auto constructor = std::get<0>(helper.destTypeConstant(type)); auto constructor = std::get<0>(helper.destTypeConstant(type));
if (auto* typeMember = util::valueOrNullptr(annotation().members.at(constructor), _memberName)) if (auto* typeMember = util::valueOrNullptr(annotation().members.at(constructor), _memberName))
{
return polymorphicInstance(typeMember->type); return polymorphicInstance(typeMember->type);
}
else else
{ {
m_errorReporter.typeError(0000_error, _location, fmt::format("Member {} not found in type {}.", _memberName, TypeEnvironmentHelpers{*m_env}.typeToString(_type))); m_errorReporter.typeError(0000_error, _location, fmt::format("Member {} not found in type {}.", _memberName, TypeEnvironmentHelpers{*m_env}.typeToString(_type)));
@ -809,7 +807,7 @@ experimental::Type TypeInference::memberType(Type _type, std::string _memberName
void TypeInference::endVisit(MemberAccess const& _memberAccess) void TypeInference::endVisit(MemberAccess const& _memberAccess)
{ {
auto &memberAccessAnnotation = annotation(_memberAccess); auto& memberAccessAnnotation = annotation(_memberAccess);
solAssert(!memberAccessAnnotation.type); solAssert(!memberAccessAnnotation.type);
Type expressionType = getType(_memberAccess.expression()); Type expressionType = getType(_memberAccess.expression());
memberAccessAnnotation.type = memberType(expressionType, _memberAccess.memberName(), _memberAccess.location()); memberAccessAnnotation.type = memberType(expressionType, _memberAccess.memberName(), _memberAccess.location());
@ -820,22 +818,22 @@ bool TypeInference::visit(TypeDefinition const& _typeDefinition)
TypeSystemHelpers helper{m_typeSystem}; TypeSystemHelpers helper{m_typeSystem};
auto& typeDefinitionAnnotation = annotation(_typeDefinition); auto& typeDefinitionAnnotation = annotation(_typeDefinition);
if (typeDefinitionAnnotation.type) if (typeDefinitionAnnotation.type)
return false; return false;
if (_typeDefinition.arguments()) if (_typeDefinition.arguments())
_typeDefinition.arguments()->accept(*this); _typeDefinition.arguments()->accept(*this);
std::optional<Type> underlyingType; std::optional<Type> underlyingType;
if (_typeDefinition.typeExpression()) if (_typeDefinition.typeExpression())
{ {
ScopedSaveAndRestore expressionContext{m_expressionContext, ExpressionContext::Type}; ScopedSaveAndRestore expressionContext{m_expressionContext, ExpressionContext::Type};
_typeDefinition.typeExpression()->accept(*this); _typeDefinition.typeExpression()->accept(*this);
underlyingType = annotation(*_typeDefinition.typeExpression()).type; underlyingType = annotation(*_typeDefinition.typeExpression()).type;
} }
std::vector<Type> arguments; std::vector<Type> arguments;
if (_typeDefinition.arguments()) if (_typeDefinition.arguments())
for (size_t i = 0; i < _typeDefinition.arguments()->parameters().size(); ++i) for (size_t i = 0; i < _typeDefinition.arguments()->parameters().size(); ++i)
arguments.emplace_back(m_typeSystem.freshTypeVariable({})); arguments.emplace_back(m_typeSystem.freshTypeVariable({}));
Type definedType = type(&_typeDefinition, arguments); Type definedType = type(&_typeDefinition, arguments);
@ -865,43 +863,43 @@ void TypeInference::endVisit(FunctionCall const& _functionCall)
TypeSystemHelpers helper{m_typeSystem}; TypeSystemHelpers helper{m_typeSystem};
std::vector<Type> argTypes; std::vector<Type> argTypes;
for(auto arg: _functionCall.arguments()) for (auto arg: _functionCall.arguments())
{ {
switch(m_expressionContext) switch (m_expressionContext)
{ {
case ExpressionContext::Term: case ExpressionContext::Term:
case ExpressionContext::Type: case ExpressionContext::Type:
argTypes.emplace_back(getType(*arg)); argTypes.emplace_back(getType(*arg));
break; break;
case ExpressionContext::Sort: case ExpressionContext::Sort:
m_errorReporter.typeError(0000_error, _functionCall.location(), "Function call in sort context."); m_errorReporter.typeError(0000_error, _functionCall.location(), "Function call in sort context.");
functionCallAnnotation.type = m_typeSystem.freshTypeVariable({}); functionCallAnnotation.type = m_typeSystem.freshTypeVariable({});
break; break;
} }
} }
switch(m_expressionContext) switch (m_expressionContext)
{ {
case ExpressionContext::Term: case ExpressionContext::Term:
{ {
Type argTuple = helper.tupleType(argTypes); Type argTuple = helper.tupleType(argTypes);
Type resultType = m_typeSystem.freshTypeVariable({}); Type resultType = m_typeSystem.freshTypeVariable({});
Type genericFunctionType = helper.functionType(argTuple, resultType); Type genericFunctionType = helper.functionType(argTuple, resultType);
unify(functionType, genericFunctionType, _functionCall.location()); unify(functionType, genericFunctionType, _functionCall.location());
functionCallAnnotation.type = resultType; functionCallAnnotation.type = resultType;
break; break;
} }
case ExpressionContext::Type: case ExpressionContext::Type:
{ {
Type argTuple = helper.tupleType(argTypes); Type argTuple = helper.tupleType(argTypes);
Type resultType = m_typeSystem.freshTypeVariable({}); Type resultType = m_typeSystem.freshTypeVariable({});
Type genericFunctionType = helper.typeFunctionType(argTuple, resultType); Type genericFunctionType = helper.typeFunctionType(argTuple, resultType);
unify(functionType, genericFunctionType, _functionCall.location()); unify(functionType, genericFunctionType, _functionCall.location());
functionCallAnnotation.type = resultType; functionCallAnnotation.type = resultType;
break; break;
} }
case ExpressionContext::Sort: case ExpressionContext::Sort:
solAssert(false); solAssert(false);
} }
} }
@ -914,10 +912,10 @@ std::optional<rational> parseRational(std::string const& _value)
rational value; rational value;
try try
{ {
auto radixPoint = find(_value.begin(), _value.end(), '.'); auto radixPoint = find(_value.begin(), _value.end(), '.');
if (radixPoint != _value.end()) if (radixPoint != _value.end())
{ {
if ( if (
!all_of(radixPoint + 1, _value.end(), util::isDigit) || !all_of(radixPoint + 1, _value.end(), util::isDigit) ||
!all_of(_value.begin(), radixPoint, util::isDigit) !all_of(_value.begin(), radixPoint, util::isDigit)
@ -941,14 +939,14 @@ std::optional<rational> parseRational(std::string const& _value)
); );
numerator = bigint(std::string(_value.begin(), radixPoint)); numerator = bigint(std::string(_value.begin(), radixPoint));
value = numerator + denominator; value = numerator + denominator;
} }
else else
value = bigint(_value); value = bigint(_value);
return value; return value;
} }
catch (...) catch (...)
{ {
return std::nullopt; return std::nullopt;
} }
} }
@ -964,19 +962,19 @@ std::optional<rational> rationalValue(Literal const& _literal)
rational value; rational value;
try try
{ {
ASTString valueString = _literal.valueWithoutUnderscores(); ASTString valueString = _literal.valueWithoutUnderscores();
auto expPoint = find(valueString.begin(), valueString.end(), 'e'); auto expPoint = find(valueString.begin(), valueString.end(), 'e');
if (expPoint == valueString.end()) if (expPoint == valueString.end())
expPoint = find(valueString.begin(), valueString.end(), 'E'); expPoint = find(valueString.begin(), valueString.end(), 'E');
if (boost::starts_with(valueString, "0x")) if (boost::starts_with(valueString, "0x"))
{ {
// process as hex // process as hex
value = bigint(valueString); value = bigint(valueString);
} }
else if (expPoint != valueString.end()) else if (expPoint != valueString.end())
{ {
// Parse mantissa and exponent. Checks numeric limit. // Parse mantissa and exponent. Checks numeric limit.
std::optional<rational> mantissa = parseRational(std::string(valueString.begin(), expPoint)); std::optional<rational> mantissa = parseRational(std::string(valueString.begin(), expPoint));
@ -1013,47 +1011,47 @@ std::optional<rational> rationalValue(Literal const& _literal)
expAbs expAbs
); );
} }
} }
else else
{ {
// parse as rational number // parse as rational number
std::optional<rational> tmp = parseRational(valueString); std::optional<rational> tmp = parseRational(valueString);
if (!tmp) if (!tmp)
return std::nullopt; return std::nullopt;
value = *tmp; value = *tmp;
} }
} }
catch (...) catch (...)
{ {
return std::nullopt; return std::nullopt;
} }
switch (_literal.subDenomination()) switch (_literal.subDenomination())
{ {
case Literal::SubDenomination::None: case Literal::SubDenomination::None:
case Literal::SubDenomination::Wei: case Literal::SubDenomination::Wei:
case Literal::SubDenomination::Second: case Literal::SubDenomination::Second:
break; break;
case Literal::SubDenomination::Gwei: case Literal::SubDenomination::Gwei:
value *= bigint("1000000000"); value *= bigint("1000000000");
break; break;
case Literal::SubDenomination::Ether: case Literal::SubDenomination::Ether:
value *= bigint("1000000000000000000"); value *= bigint("1000000000000000000");
break; break;
case Literal::SubDenomination::Minute: case Literal::SubDenomination::Minute:
value *= bigint("60"); value *= bigint("60");
break; break;
case Literal::SubDenomination::Hour: case Literal::SubDenomination::Hour:
value *= bigint("3600"); value *= bigint("3600");
break; break;
case Literal::SubDenomination::Day: case Literal::SubDenomination::Day:
value *= bigint("86400"); value *= bigint("86400");
break; break;
case Literal::SubDenomination::Week: case Literal::SubDenomination::Week:
value *= bigint("604800"); value *= bigint("604800");
break; break;
case Literal::SubDenomination::Year: case Literal::SubDenomination::Year:
value *= bigint("31536000"); value *= bigint("31536000");
break; break;
} }
return value; return value;
@ -1065,19 +1063,19 @@ bool TypeInference::visit(Literal const& _literal)
auto& literalAnnotation = annotation(_literal); auto& literalAnnotation = annotation(_literal);
if (_literal.token() != Token::Number) if (_literal.token() != Token::Number)
{ {
m_errorReporter.typeError(0000_error, _literal.location(), "Only number literals are supported."); m_errorReporter.typeError(0000_error, _literal.location(), "Only number literals are supported.");
return false; return false;
} }
std::optional<rational> value = rationalValue(_literal); std::optional<rational> value = rationalValue(_literal);
if (!value) if (!value)
{ {
m_errorReporter.typeError(0000_error, _literal.location(), "Invalid number literals."); m_errorReporter.typeError(0000_error, _literal.location(), "Invalid number literals.");
return false; return false;
} }
if (value->denominator() != 1) if (value->denominator() != 1)
{ {
m_errorReporter.typeError(0000_error, _literal.location(), "Only integers are supported."); m_errorReporter.typeError(0000_error, _literal.location(), "Only integers are supported.");
return false; return false;
} }
literalAnnotation.type = m_typeSystem.freshTypeVariable(Sort{{annotation().builtinClasses.at(BuiltinClass::Integer)}}); literalAnnotation.type = m_typeSystem.freshTypeVariable(Sort{{annotation().builtinClasses.at(BuiltinClass::Integer)}});
return false; return false;
@ -1091,7 +1089,7 @@ TypeRegistration::TypeClassInstantiations const& typeClassInstantiations(Analysi
{ {
auto const* typeClassDeclaration = _analysis.typeSystem().typeClassDeclaration(_class); auto const* typeClassDeclaration = _analysis.typeSystem().typeClassDeclaration(_class);
if (typeClassDeclaration) if (typeClassDeclaration)
return _analysis.annotation<TypeRegistration>(*typeClassDeclaration).instantiations; return _analysis.annotation<TypeRegistration>(*typeClassDeclaration).instantiations;
// TODO: better mechanism than fetching by name. // TODO: better mechanism than fetching by name.
auto& annotation = _analysis.annotation<TypeRegistration>(); auto& annotation = _analysis.annotation<TypeRegistration>();
auto& inferenceAnnotation = _analysis.annotation<TypeInference>(); auto& inferenceAnnotation = _analysis.annotation<TypeInference>();

View File

@ -61,7 +61,7 @@ bool TypeRegistration::visit(ElementaryTypeName const& _typeName)
if (annotation(_typeName).typeConstructor) if (annotation(_typeName).typeConstructor)
return false; return false;
annotation(_typeName).typeConstructor = [&]() -> std::optional<TypeConstructor> { annotation(_typeName).typeConstructor = [&]() -> std::optional<TypeConstructor> {
switch(_typeName.typeName().token()) switch (_typeName.typeName().token())
{ {
case Token::Void: case Token::Void:
return m_typeSystem.constructor(PrimitiveType::Void); return m_typeSystem.constructor(PrimitiveType::Void);

View File

@ -72,12 +72,12 @@ std::vector<TypeEnvironment::UnificationFailure> TypeEnvironment::unify(Type _a,
failures += instantiate(_var, _a); failures += instantiate(_var, _a);
}, },
[&](TypeConstant _left, TypeConstant _right) { [&](TypeConstant _left, TypeConstant _right) {
if(_left.constructor != _right.constructor) if (_left.constructor != _right.constructor)
return unificationFailure(); return unificationFailure();
if (_left.arguments.size() != _right.arguments.size()) if (_left.arguments.size() != _right.arguments.size())
return unificationFailure(); return unificationFailure();
for (auto&& [left, right]: ranges::zip_view(_left.arguments, _right.arguments)) for (auto&& [left, right]: ranges::zip_view(_left.arguments, _right.arguments))
failures += unify(left, right); failures += unify(left, right);
}, },
[&](auto, auto) { [&](auto, auto) {
unificationFailure(); unificationFailure();
@ -98,14 +98,14 @@ bool TypeEnvironment::typeEquals(Type _lhs, Type _rhs) const
return false; return false;
}, },
[&](TypeConstant _left, TypeConstant _right) { [&](TypeConstant _left, TypeConstant _right) {
if(_left.constructor != _right.constructor) if (_left.constructor != _right.constructor)
return false; return false;
if (_left.arguments.size() != _right.arguments.size()) if (_left.arguments.size() != _right.arguments.size())
return false; return false;
for (auto&& [left, right]: ranges::zip_view(_left.arguments, _right.arguments)) for (auto&& [left, right]: ranges::zip_view(_left.arguments, _right.arguments))
if (!typeEquals(left, right)) if (!typeEquals(left, right))
return false; return false;
return true; return true;
}, },
[&](auto, auto) { [&](auto, auto) {
return false; return false;
@ -133,7 +133,7 @@ TypeSystem::TypeSystem()
m_primitiveTypeClasses.emplace(PrimitiveClass::Type, declarePrimitiveClass("type")); m_primitiveTypeClasses.emplace(PrimitiveClass::Type, declarePrimitiveClass("type"));
for (auto [type, name, arity]: std::initializer_list<std::tuple<PrimitiveType, const char*, uint64_t>> { for (auto [type, name, arity]: std::initializer_list<std::tuple<PrimitiveType, char const*, uint64_t>>{
{PrimitiveType::TypeFunction, "tfun", 2}, {PrimitiveType::TypeFunction, "tfun", 2},
{PrimitiveType::Function, "fun", 2}, {PrimitiveType::Function, "fun", 2},
{PrimitiveType::Function, "itself", 1}, {PrimitiveType::Function, "itself", 1},
@ -184,7 +184,7 @@ std::vector<TypeEnvironment::UnificationFailure> TypeEnvironment::instantiate(Ty
experimental::Type TypeEnvironment::resolve(Type _type) const experimental::Type TypeEnvironment::resolve(Type _type) const
{ {
Type result = _type; Type result = _type;
while(auto const* var = std::get_if<TypeVariable>(&result)) while (auto const* var = std::get_if<TypeVariable>(&result))
if (Type const* resolvedType = util::valueOrNullptr(m_typeVariables, var->index())) if (Type const* resolvedType = util::valueOrNullptr(m_typeVariables, var->index()))
result = *resolvedType; result = *resolvedType;
else else

View File

@ -54,7 +54,7 @@ using namespace solidity::frontend::experimental;
std::optional<TypeConstructor> experimental::typeConstructorFromToken(Analysis const& _analysis, langutil::Token _token) std::optional<TypeConstructor> experimental::typeConstructorFromToken(Analysis const& _analysis, langutil::Token _token)
{ {
TypeSystem const& typeSystem = _analysis.typeSystem(); TypeSystem const& typeSystem = _analysis.typeSystem();
switch(_token) switch (_token)
{ {
case Token::Void: case Token::Void:
return typeSystem.builtinConstructor(BuiltinType::Void); return typeSystem.builtinConstructor(BuiltinType::Void);
@ -142,7 +142,7 @@ std::vector<experimental::Type> TypeSystemHelpers::destTupleType(Type _tupleType
std::vector<Type> result; std::vector<Type> result;
result.emplace_back(arguments.front()); result.emplace_back(arguments.front());
Type tail = arguments.back(); Type tail = arguments.back();
while(true) while (true)
{ {
if (!isTypeConstant(tail)) if (!isTypeConstant(tail))
break; break;
@ -184,7 +184,7 @@ std::vector<experimental::Type> TypeSystemHelpers::destSumType(Type _tupleType)
std::vector<Type> result; std::vector<Type> result;
result.emplace_back(arguments.front()); result.emplace_back(arguments.front());
Type tail = arguments.back(); Type tail = arguments.back();
while(true) while (true)
{ {
if (!isTypeConstant(tail)) if (!isTypeConstant(tail))
break; break;
@ -338,22 +338,22 @@ std::string TypeEnvironmentHelpers::typeToString(Type const& _type) const
{ {
std::map<TypeConstructor, std::function<std::string(std::vector<Type>)>> formatters{ std::map<TypeConstructor, std::function<std::string(std::vector<Type>)>> formatters{
{env.typeSystem().constructor(PrimitiveType::Function), [&](auto const& _args) { {env.typeSystem().constructor(PrimitiveType::Function), [&](auto const& _args) {
solAssert(_args.size() == 2); solAssert(_args.size() == 2);
return fmt::format("{} -> {}", typeToString(_args.front()), typeToString(_args.back())); return fmt::format("{} -> {}", typeToString(_args.front()), typeToString(_args.back()));
}}, }},
{env.typeSystem().constructor(PrimitiveType::Unit), [&](auto const& _args) { {env.typeSystem().constructor(PrimitiveType::Unit), [&](auto const& _args) {
solAssert(_args.size() == 0); solAssert(_args.size() == 0);
return "()"; return "()";
}}, }},
{env.typeSystem().constructor(PrimitiveType::Pair), [&](auto const& _arguments) { {env.typeSystem().constructor(PrimitiveType::Pair), [&](auto const& _arguments) {
auto tupleTypes = TypeSystemHelpers{env.typeSystem()}.destTupleType(_arguments.back()); auto tupleTypes = TypeSystemHelpers{env.typeSystem()}.destTupleType(_arguments.back());
std::string result = "("; std::string result = "(";
result += typeToString(_arguments.front()); result += typeToString(_arguments.front());
for (auto type: tupleTypes) for (auto type: tupleTypes)
result += ", " + typeToString(type); result += ", " + typeToString(type);
result += ")"; result += ")";
return result; return result;
}}, }},
}; };
return std::visit(util::GenericVisitor{ return std::visit(util::GenericVisitor{
[&](TypeConstant const& _type) { [&](TypeConstant const& _type) {

View File

@ -46,7 +46,8 @@ std::string IRGeneratorForStatements::generate(ASTNode const& _node)
} }
namespace { namespace
{
struct CopyTranslate: public yul::ASTCopier struct CopyTranslate: public yul::ASTCopier
{ {
@ -300,7 +301,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
auto declaration = m_expressionDeclaration.at(&_functionCall.expression()); auto declaration = m_expressionDeclaration.at(&_functionCall.expression());
if (auto builtin = std::get_if<Builtins>(&declaration)) if (auto builtin = std::get_if<Builtins>(&declaration))
{ {
switch(*builtin) switch (*builtin)
{ {
case Builtins::FromBool: case Builtins::FromBool:
case Builtins::Identity: case Builtins::Identity:

View File

@ -486,7 +486,7 @@ bool CompilerStack::analyze()
for (Source const* source: m_sourceOrder) for (Source const* source: m_sourceOrder)
if (source->ast && !docStringTagParser.parseDocStrings(*source->ast)) if (source->ast && !docStringTagParser.parseDocStrings(*source->ast))
noErrors = false; noErrors = false;
} }
// Requires DocStringTagParser // Requires DocStringTagParser
for (Source const* source: m_sourceOrder) for (Source const* source: m_sourceOrder)

View File

@ -2076,7 +2076,7 @@ int Parser::tokenPrecedence(Token _token) const
{ {
if (m_experimentalSolidityEnabledInCurrentSourceUnit) if (m_experimentalSolidityEnabledInCurrentSourceUnit)
{ {
switch(_token) switch (_token)
{ {
case Token::Colon: case Token::Colon:
return 1000; return 1000;