mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-05 22:48:43 +00:00
check_no_pass_type_in_argumets func
This commit is contained in:
parent
1a9408c2f6
commit
ed4b984b81
3 changed files with 18 additions and 1 deletions
|
|
@ -229,4 +229,8 @@ find_name_definition_handle_errors(const std::string &name,
|
||||||
void type_check_error(const std::string &message, const nodes::Node &node,
|
void type_check_error(const std::string &message, const nodes::Node &node,
|
||||||
SourcesManager &sources_manager);
|
SourcesManager &sources_manager);
|
||||||
|
|
||||||
|
bool check_no_pass_type_in_arguments(const Arguments &arguments,
|
||||||
|
const nodes::Node &node,
|
||||||
|
SourcesManager &sources_manager);
|
||||||
|
|
||||||
} // namespace type_check
|
} // namespace type_check
|
||||||
|
|
|
||||||
|
|
@ -545,6 +545,8 @@ nodes::TypeCheckResult
|
||||||
type_check_constructor(const nodes::Constructor &expression,
|
type_check_constructor(const nodes::Constructor &expression,
|
||||||
SourcesManager &sources_manager, State &state,
|
SourcesManager &sources_manager, State &state,
|
||||||
const Arguments &arguments) {
|
const Arguments &arguments) {
|
||||||
|
check_no_pass_type_in_arguments(arguments, expression, sources_manager);
|
||||||
|
|
||||||
const auto maybe_type_definition = find_type_definition_handle_errors(
|
const auto maybe_type_definition = find_type_definition_handle_errors(
|
||||||
*expression.get_type()->get_name()->get(), expression, sources_manager);
|
*expression.get_type()->get_name()->get(), expression, sources_manager);
|
||||||
if (!maybe_type_definition.has_value()) {
|
if (!maybe_type_definition.has_value()) {
|
||||||
|
|
@ -620,7 +622,7 @@ nodes::TypeCheckResult type_check_lambda(const nodes::Lambda &expression,
|
||||||
// auto returned_type = type_check_expression(
|
// auto returned_type = type_check_expression(
|
||||||
// *expression.get_expression(), sources_manager, state, Arguments{});
|
// *expression.get_expression(), sources_manager, state, Arguments{});
|
||||||
|
|
||||||
return nodes::TypeCheckResult{expected_type};
|
return nodes::TypeCheckResult{expected_type}; // TODO: same to expected ??
|
||||||
} // IN PROGRESS
|
} // IN PROGRESS
|
||||||
|
|
||||||
} // namespace type_check
|
} // namespace type_check
|
||||||
|
|
|
||||||
|
|
@ -72,4 +72,15 @@ void type_check_error(const std::string &message, const nodes::Node &node,
|
||||||
node, message, error_handling::ErrorType::TYPE_CHECK));
|
node, message, error_handling::ErrorType::TYPE_CHECK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool check_no_pass_type_in_arguments(const Arguments &arguments,
|
||||||
|
const nodes::Node &node,
|
||||||
|
SourcesManager &sources_manager) {
|
||||||
|
if (arguments.get_passed().has_value()) {
|
||||||
|
type_check_error("Type can't be passed to this node", node,
|
||||||
|
sources_manager);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace type_check
|
} // namespace type_check
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue