Skip to content
Snippets Groups Projects
Commit a6720a7a authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Fix builtin function call disambiguation

In the case of multiple function candidates, if one was an exact
match, it was incorrectly considered an ambiguous call.
parent b3933a07
No related branches found
No related tags found
1 merge request!86Fix builtin function call disambiguation
...@@ -233,12 +233,20 @@ getBuiltinFunctionEmbedder(ASTNode& n) ...@@ -233,12 +233,20 @@ getBuiltinFunctionEmbedder(ASTNode& n)
return callable_id_list[0]; return callable_id_list[0];
} }
default: { default: {
auto& builtin_function_embedder_table = n.m_symbol_table->builtinFunctionEmbedderTable();
for (auto callable_id : callable_id_list) {
std::shared_ptr builtin_function_embedder = builtin_function_embedder_table[callable_id];
// If has exact match return it
if (dataTypeName(args_node.m_data_type) == dataTypeName(builtin_function_embedder->getParameterDataTypes())) {
return callable_id;
}
}
// else this is an ambiguous call
std::ostringstream error_msg; std::ostringstream error_msg;
error_msg << "ambiguous function call " << rang::fgB::red << builtin_function_name << rang::style::reset error_msg << "ambiguous function call " << rang::fgB::red << builtin_function_name << rang::style::reset
<< rang::style::bold << ": " << rang::fgB::yellow << dataTypeName(args_node.m_data_type) << rang::style::bold << ": " << rang::fgB::yellow << dataTypeName(args_node.m_data_type)
<< rang::style::reset << rang::style::bold << "\nnote: candidates are"; << rang::style::reset << rang::style::bold << "\nnote: candidates are";
auto& builtin_function_embedder_table = n.m_symbol_table->builtinFunctionEmbedderTable();
for (auto callable_id : callable_id_list) { for (auto callable_id : callable_id_list) {
std::shared_ptr builtin_function_embedder = builtin_function_embedder_table[callable_id]; std::shared_ptr builtin_function_embedder = builtin_function_embedder_table[callable_id];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment