bugfix: reprEnum for enums with negative values
This commit is contained in:
parent
28e375c4f6
commit
a431207e52
1 changed files with 5 additions and 1 deletions
|
|
@ -59,7 +59,11 @@ 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 = e and (1 shl (typ.size*8)-1)
|
||||
let e = if typ.size == 1: e and 0xff
|
||||
elif typ.size == 2: e and 0xffff
|
||||
else: e
|
||||
# XXX we need a proper narrowing based on signedness here
|
||||
#e and ((1 shl (typ.size*8)) - 1)
|
||||
if ntfEnumHole notin typ.flags:
|
||||
if e <% typ.node.len:
|
||||
return $typ.node.sons[e].name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue