fixes #3985
This commit is contained in:
parent
b57d14b1ae
commit
2c1f1f21bf
3 changed files with 21 additions and 3 deletions
|
|
@ -375,7 +375,12 @@ proc getAppType(n: PNode): PNode =
|
|||
result = newStrNodeT("console", n)
|
||||
|
||||
proc rangeCheck(n: PNode, value: BiggestInt) =
|
||||
if value < firstOrd(n.typ) or value > lastOrd(n.typ):
|
||||
var err = false
|
||||
if n.typ.skipTypes({tyRange}).kind in {tyUInt..tyUInt64}:
|
||||
err = value <% firstOrd(n.typ) or value >% lastOrd(n.typ, fixedUnsigned=true)
|
||||
else:
|
||||
err = value < firstOrd(n.typ) or value > lastOrd(n.typ)
|
||||
if err:
|
||||
localError(n.info, errGenerated, "cannot convert " & $value &
|
||||
" to " & typeToString(n.typ))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue