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

Add test to ensure that function calls only applies to function

The following code is now invalid
``
R x = 3;
x(0); // x is not a function
``
parent 224357cb
Branches
Tags
1 merge request!37Feature/language
......@@ -199,6 +199,12 @@ ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n)
throw parse_error(message.str(), n.begin());
}
} else if (n.is<language::function_evaluation>()) {
if (n.children[0]->m_data_type != ASTNodeDataType::function_t) {
std::ostringstream message;
message << "invalid function call\n"
<< "note: '" << n.children[0]->string() << "' is not a function!" << std::ends;
throw parse_error(message.str(), n.begin());
}
std::cout << rang::fgB::red << "returned type of function evaluation is incorrect" << rang::style::reset << "\n";
n.m_data_type = ASTNodeDataType::double_t;
} else if (n.is<language::B_set>() or n.is<language::Z_set>() or n.is<language::N_set>() or
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment