diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2019-01-22 14:43:17 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-22 14:43:17 -0600 |
commit | af1714ddc446fe6e239852374f5f628302980488 (patch) | |
tree | 740ab1db31cdab76bcbcfdbda81d127a9552018a /src/expr | |
parent | f7ebbd30653cffa3412b914f5813302bd2101578 (diff) |
Fix parsing of overloaded parametric datatype selectors (#2819)
Diffstat (limited to 'src/expr')
-rw-r--r-- | src/expr/symbol_table.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/expr/symbol_table.cpp b/src/expr/symbol_table.cpp index 32126cf4e..9401e772c 100644 --- a/src/expr/symbol_table.cpp +++ b/src/expr/symbol_table.cpp @@ -203,8 +203,31 @@ Expr OverloadedTypeTrie::getOverloadedFunctionForTypes( if (itc != tat->d_children.end()) { tat = &itc->second; } else { - // no functions match - return d_nullExpr; + Trace("parser-overloading") + << "Could not find overloaded function " << name << std::endl; + // it may be a parametric datatype + TypeNode tna = TypeNode::fromType(argTypes[i]); + if (tna.isParametricDatatype()) + { + Trace("parser-overloading") + << "Parametric overloaded datatype selector " << name << " " + << tna << std::endl; + DatatypeType tnd = static_cast<DatatypeType>(argTypes[i]); + const Datatype& dt = tnd.getDatatype(); + // tng is the "generalized" version of the instantiated parametric + // type tna + Type tng = dt.getDatatypeType(); + itc = tat->d_children.find(tng); + if (itc != tat->d_children.end()) + { + tat = &itc->second; + } + } + if (tat == nullptr) + { + // no functions match + return d_nullExpr; + } } } // we ensure that there is *only* one active symbol at this node |