summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-12-19 10:03:55 +0100
committerGitHub <noreply@github.com>2018-12-19 10:03:55 +0100
commit3f917c8d914fdd26023703acd046dc2b4a8105dd (patch)
tree06064a1b001a5b7bfd72bbb7f05f5777c41f7a66
parent72500420d36172af18262937b5300e3a8a698a47 (diff)
parentf233b2fe8b0659674f10def4365a1c13f9bdebb8 (diff)
downloadNim-3f917c8d914fdd26023703acd046dc2b4a8105dd.tar.gz
Merge pull request #9959 from nc-x/better-error-message
Better error messages in enums which don't have ordinal types
-rw-r--r--compiler/semtypes.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index 29bdc2bd7..dc27e5823 100644
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -91,7 +91,7 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
           strVal = v.sons[1] # second tuple part is the string value
           if skipTypes(strVal.typ, abstractInst).kind in {tyString, tyCString}:
             if not isOrdinalType(v.sons[0].typ, allowEnumWithHoles=true):
-              localError(c.config, v.sons[0].info, errOrdinalTypeExpected)
+              localError(c.config, v.sons[0].info, errOrdinalTypeExpected & "; given: " & typeToString(v.sons[0].typ, preferDesc))
             x = getOrdValue(v.sons[0]) # first tuple part is the ordinal
           else:
             localError(c.config, strVal.info, errStringLiteralExpected)
@@ -102,7 +102,7 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
         x = counter
       else:
         if not isOrdinalType(v.typ, allowEnumWithHoles=true):
-          localError(c.config, v.info, errOrdinalTypeExpected)
+          localError(c.config, v.info, errOrdinalTypeExpected & "; given: " & typeToString(v.typ, preferDesc))
         x = getOrdValue(v)
       if i != 1:
         if x != counter: incl(result.flags, tfEnumHasHoles)