Skip to content

Commit

Permalink
Handle type parameters in type of default expression
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Jun 21, 2024
1 parent 28695a2 commit 4584fa6
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ void collect(current: (KeywordFormal) `<Type kwType> <Name name> = <Expression e
c.define(kwformalName, keywordFormalId(), current, dt);
c.calculate("keyword formal", current, [kwType, expression],
AType(Solver s){
s.requireSubType(expression, kwType, error(expression, "Default expression of type %t expected, found %t", kwType, expression));
expType = s.getType(expression);
// reduce any type parameters in default expression to avoid
expType = visit(expType) {
case p:aparameter(pname, _) => avoid()
};
s.requireSubType(expType, kwType, error(expression, "Default expression of type %t expected, found %t", kwType, expression));
return s.getType(kwType);
});
c.enterScope(kwType); // Wrap the type in a subscope to avoid name clashes caused by names introduced in function types
Expand Down

0 comments on commit 4584fa6

Please sign in to comment.