some progress for #1082

This commit is contained in:
Araq 2014-04-21 01:34:54 +02:00
commit 042ffed6c4
2 changed files with 11 additions and 5 deletions

View file

@ -194,10 +194,15 @@ proc semRange(c: PContext, n: PNode, prev: PType): PType =
if isRange(n[1]): if isRange(n[1]):
result = semRangeAux(c, n[1], prev) result = semRangeAux(c, n[1], prev)
let n = result.n let n = result.n
if n.sons[0].kind in {nkCharLit..nkUInt64Lit}: if n.sons[0].kind in {nkCharLit..nkUInt64Lit} and n.sons[0].intVal > 0:
if n.sons[0].intVal > 0 or n.sons[1].intVal < 0:
incl(result.flags, tfNeedsInit) incl(result.flags, tfNeedsInit)
elif n.sons[0].floatVal > 0.0 or n.sons[1].floatVal < 0.0: elif n.sons[1].kind in {nkCharLit..nkUInt64Lit} and n.sons[1].intVal < 0:
incl(result.flags, tfNeedsInit)
elif n.sons[0].kind in {nkFloatLit..nkFloat64Lit} and
n.sons[0].floatVal > 0.0:
incl(result.flags, tfNeedsInit)
elif n.sons[1].kind in {nkFloatLit..nkFloat64Lit} and
n.sons[1].floatVal < 0.0:
incl(result.flags, tfNeedsInit) incl(result.flags, tfNeedsInit)
else: else:
localError(n.sons[0].info, errRangeExpected) localError(n.sons[0].info, errRangeExpected)

View file

@ -20,7 +20,8 @@ new(a)
q(a) q(a)
# bug #914 # bug #914
var x = newWideCString("Hello") when defined(windows):
var x = newWideCString("Hello")
echo "success" echo "success"