Better case coverage error message for alias and range enum (#12913)

This commit is contained in:
Jasper Jenkins 2019-12-18 01:29:01 -08:00 • committed by Clyybber
commit 3c38edf563
6 changed files with 100 additions and 70 deletions

View file

@ -953,9 +953,9 @@ proc semCase(c: PContext, n: PNode; flags: TExprFlags): PNode =
if chckCovered:
if covered == toCover(c, n[0].typ):
hasElse = true
elif n[0].typ.kind == tyEnum:
localError(c.config, n.info, "not all cases are covered; missing: {$1}" %
formatMissingEnums(n))
elif n[0].typ.skipTypes(abstractRange).kind == tyEnum:
localError(c.config, n.info, "not all cases are covered; missing: $1" %
formatMissingEnums(c, n))
else:
localError(c.config, n.info, "not all cases are covered")
popCaseContext(c)