mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-14 10:58:45 +00:00
part of constuctor typecheck (constructors for different types)
This commit is contained in:
parent
005fb6aaf3
commit
d7f1b6c377
3 changed files with 217 additions and 59 deletions
|
|
@ -177,9 +177,10 @@ inline std::optional<size_t> get_parameters_count(Type type) {
|
|||
return std::nullopt;
|
||||
case Type::ARRAY:
|
||||
case Type::OPTIONAL:
|
||||
case Type::RESULT:
|
||||
case Type::ERROR:
|
||||
return 1;
|
||||
case Type::RESULT: // RESULT[T E] = T | Error[E]
|
||||
return 2;
|
||||
// -- basic types
|
||||
case Type::FLOAT:
|
||||
case Type::DOUBLE:
|
||||
|
|
|
|||
|
|
@ -243,6 +243,21 @@ public:
|
|||
std::move(parameters)));
|
||||
}
|
||||
|
||||
TypeProxy add_error_of(TypeProxy type, Node node = Node()) {
|
||||
if (type.type_storage_ != this) {
|
||||
error_handling::handle_general_error(
|
||||
"TypeStorage: Can't add error of type from another type "
|
||||
"storage");
|
||||
}
|
||||
|
||||
std::vector<nodes::TypeProxy> parameters;
|
||||
parameters.push_back(type);
|
||||
|
||||
return add_type(Type(Identifier(node, Identifier::SIMPLE_TYPE,
|
||||
builtin::types::ERROR_IDENTIFIER),
|
||||
std::move(parameters)));
|
||||
}
|
||||
|
||||
nodes::TypeProxy add_container_of(std::vector<TypeProxy> &¶meters,
|
||||
builtin::types::Type container,
|
||||
Node node = Node()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue