fixup! Type inference draft.

This commit is contained in:
Kamil Śliwak 2023-09-18 16:50:46 +02:00
parent 6621dc6ba5
commit 1ffd65f089
2 changed files with 5 additions and 2 deletions

View File

@ -839,7 +839,7 @@ bool TypeInference::visit(TypeDefinition const& _typeDefinition)
TypeConstructor constructor = typeConstructor(&_typeDefinition);
auto [members, newlyInserted] = annotation().members.emplace(constructor, std::map<std::string, TypeMember>{});
solAssert(newlyInserted);
solAssert(newlyInserted, fmt::format("Members of type '{}' are already defined.", m_typeSystem.constructorInfo(constructor).name));
if (underlyingType)
{
members->second.emplace("abs", TypeMember{helper.functionType(*underlyingType, definedType)});

View File

@ -297,7 +297,10 @@ experimental::Type TypeSystem::type(TypeConstructor _constructor, std::vector<Ty
{
// TODO: proper error handling
auto const& info = m_typeConstructors.at(_constructor.m_index);
solAssert(info.arguments() == _arguments.size(), "Invalid arity.");
solAssert(
info.arguments() == _arguments.size(),
fmt::format("Type constructor '{}' accepts {} type arguments (got {}).", constructorInfo(_constructor).name, info.arguments(), _arguments.size())
);
return TypeConstant{_constructor, _arguments};
}