From e8ff987cefbc40f991e78111cbb69d436fdd2708 Mon Sep 17 00:00:00 2001 From: gmpreussner Date: Mon, 14 Mar 2016 21:58:28 -0400 Subject: [PATCH] Fixed negative enum values not getting stringified. --- lib/system/repr.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/system/repr.nim b/lib/system/repr.nim index 831515eb17..4e9b07c075 100644 --- a/lib/system/repr.nim +++ b/lib/system/repr.nim @@ -74,9 +74,9 @@ proc reprChar(x: char): string {.compilerRtl.} = proc reprEnum(e: int, typ: PNimType): string {.compilerRtl.} = # we read an 'int' but this may have been too large, so mask the other bits: - let e = if typ.size == 1: e and 0xff - elif typ.size == 2: e and 0xffff - elif typ.size == 4: e and 0xffffffff + let e = if typ.size == 1: int(int8(e)) + elif typ.size == 2: int(int16(e)) + elif typ.size == 4: int(int32(e)) else: e # XXX we need a proper narrowing based on signedness here #e and ((1 shl (typ.size*8)) - 1)