diff options
author | Araq <rumpf_a@web.de> | 2012-01-29 13:38:23 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-01-29 13:38:23 +0100 |
commit | 1ba3dbc7595a40bdb68973d0863c904657ca28f6 (patch) | |
tree | be239af216de9221d51a196ced116d92ebf2d3e9 | |
parent | e27da767a2e833966a418d805abb45a9f172be47 (diff) | |
download | Nim-1ba3dbc7595a40bdb68973d0863c904657ca28f6.tar.gz |
bugfix tests/tzeroarray
-rwxr-xr-x | compiler/cgen.nim | 3 | ||||
-rw-r--r-- | tests/run/tzeroarray.nim | 18 | ||||
-rwxr-xr-x | todo.txt | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 6a5d890a8..5de2481ed 100755 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -405,6 +405,9 @@ proc assignGlobalVar(p: BProc, s: PSym) = if sfRegister in s.flags: app(p.module.s[cfsVars], " register") if sfVolatile in s.flags: app(p.module.s[cfsVars], " volatile") 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} == {optStackTrace, optEndb}: appcg(p.module, p.module.s[cfsDebugInit], diff --git a/tests/run/tzeroarray.nim b/tests/run/tzeroarray.nim new file mode 100644 index 000000000..7f66007b5 --- /dev/null +++ b/tests/run/tzeroarray.nim @@ -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" + diff --git a/todo.txt b/todo.txt index dc9f9c159..22a4c6d97 100755 --- a/todo.txt +++ b/todo.txt @@ -48,6 +48,7 @@ Bugs without ``-d:release`` leaks memory; good way to figure out how a fixed amount of stack can hold an arbitrary number of GC roots! - bug: temp2.nim triggers weird compiler and except.nim bug +- bug: negative array indexes fail to index check version 0.9.XX |