Skip to content

Commit

Permalink
added proper type check error in case the default value of a keyword …
Browse files Browse the repository at this point in the history
…parameter does not fit its declared type. Fixes #1866
  • Loading branch information
jurgenvinju committed Sep 22, 2023
1 parent 9bddad9 commit d3548dd
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,12 @@ public Result<IValue> computeDefaultKeywordParameter(String label, IConstructor
}
else {
Expression def = getKeywordParameterDefaults().get(kwparam);
kwResult = ResultFactory.makeResult(kwType, def.interpret(eval).value, ctx);
IValue res = def.interpret(eval).value;

if (!res.getType().isSubtypeOf(kwType)) {
throw new UnexpectedKeywordArgumentType(kwparam, kwType, res.getType(), ctx.getCurrentAST());
}
kwResult = ResultFactory.makeResult(kwType, value, ctx);
}

if (kwparam.equals(label)) {
Expand Down

0 comments on commit d3548dd

Please sign in to comment.