summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorNeelesh Chandola <neelesh.chandola@outlook.com>2018-12-13 11:28:50 +0530
committerNeelesh Chandola <neelesh.chandola@outlook.com>2018-12-13 15:07:36 +0530
commit31cff752e0687b663d15ebfa71a57d5723c5b876 (patch)
tree315dbd52d177b0fba57fd887b55fae703d693927
parente4ae7a892948304e7317e3d8cc8d00cf9a91228c (diff)
downloadNim-31cff752e0687b663d15ebfa71a57d5723c5b876.tar.gz
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 f4ff97ba4..97ee062d1 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):
-              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):
-          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)