bugfix tests/tzeroarray

This commit is contained in:
Araq 2012-01-29 13:38:23 +01:00
commit 1ba3dbc759
3 changed files with 22 additions and 0 deletions

View file

@ -405,6 +405,9 @@ proc assignGlobalVar(p: BProc, s: PSym) =
if sfRegister in s.flags: app(p.module.s[cfsVars], " register") if sfRegister in s.flags: app(p.module.s[cfsVars], " register")
if sfVolatile in s.flags: app(p.module.s[cfsVars], " volatile") if sfVolatile in s.flags: app(p.module.s[cfsVars], " volatile")
appf(p.module.s[cfsVars], " $1;$n", [s.loc.r]) appf(p.module.s[cfsVars], " $1;$n", [s.loc.r])
if p.withinLoop > 0:
# fixes tests/run/tzeroarray:
initLocalVar(p, s, false)
if p.module.module.options * {optStackTrace, optEndb} == if p.module.module.options * {optStackTrace, optEndb} ==
{optStackTrace, optEndb}: {optStackTrace, optEndb}:
appcg(p.module, p.module.s[cfsDebugInit], appcg(p.module, p.module.s[cfsDebugInit],

18
tests/run/tzeroarray.nim Normal file
View file

@ -0,0 +1,18 @@
discard """
output: 'done'
"""
for i in 0 .. 1:
var a: array[0..4, int]
if a[0] != 0: quit "bug"
a[0] = 6
proc main =
for i in 0 .. 1:
var a: array[0..4, int]
if a[0] != 0: quit "bug"
a[0] = 6
main()
echo "done"

View file

@ -48,6 +48,7 @@ Bugs
without ``-d:release`` leaks memory; good way to figure out how a without ``-d:release`` leaks memory; good way to figure out how a
fixed amount of stack can hold an arbitrary number of GC roots! fixed amount of stack can hold an arbitrary number of GC roots!
- bug: temp2.nim triggers weird compiler and except.nim bug - bug: temp2.nim triggers weird compiler and except.nim bug
- bug: negative array indexes fail to index check
version 0.9.XX version 0.9.XX