continue working on function narrowing
This commit is contained in:
@@ -411,8 +411,32 @@ namespace Solstice {
|
|||||||
std::vector<PossibleType> args;
|
std::vector<PossibleType> args;
|
||||||
|
|
||||||
// narrow types based on function
|
// narrow types based on function
|
||||||
for (auto& child : node.children[1].children) {
|
for (size_t i = 0; i < node.children[1].children.size(); i++) {
|
||||||
|
auto& child = node.children[1].children[i];
|
||||||
checkNodeType(child);
|
checkNodeType(child);
|
||||||
|
if (child.ptype.unknownType && child.type == NodeType::Identifier) {
|
||||||
|
auto id = child.getIdentifier();
|
||||||
|
if (!id.has_value()) {
|
||||||
|
throw std::runtime_error("identifier node does not contain identifier");
|
||||||
|
}
|
||||||
|
// don't bother with checking against other function combinations, the
|
||||||
|
// part of the function below will deal with that
|
||||||
|
if (child.ptype.possiblities.empty()) {
|
||||||
|
child.ptype.possiblities = function.argumentTypes[i].possiblities;
|
||||||
|
} else {
|
||||||
|
std::unordered_set<Type> newTypes;
|
||||||
|
for (const auto& type : function.argumentTypes[i].possiblities) {
|
||||||
|
if (child.ptype.possiblities.find(type) != child.ptype.possiblities.end()) {
|
||||||
|
newTypes.insert(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newTypes.empty()) {
|
||||||
|
throw std::runtime_error("no matching overload found for function " + *name);
|
||||||
|
}
|
||||||
|
child.ptype.possiblities = newTypes;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
args.push_back(child.ptype);
|
args.push_back(child.ptype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user