From 5c33f76517d5c0c1fc0bb1b8d4bba7417f2108d2 Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 23 Mar 2012 09:29:53 +0100 Subject: bugfix: GC marker procs; making tests green again --- compiler/ccgtrav.nim | 6 +++++- compiler/types.nim | 4 +++- tests/reject/t99bott.nim | 2 +- tests/reject/tenumitems.nim | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/compiler/ccgtrav.nim b/compiler/ccgtrav.nim index 995ed2973..83dda692b 100644 --- a/compiler/ccgtrav.nim +++ b/compiler/ccgtrav.nim @@ -110,7 +110,11 @@ proc genTraverseProc(m: BModule, typ: PType, reason: TTypeInfoReason): PRope = if typ.kind == tySequence: genTraverseProcSeq(c, "a".toRope, typ) else: - genTraverseProc(c, "(*a)".toRope, typ.sons[0]) + if skipTypes(typ.sons[0], abstractInst).kind in {tyArrayConstr, tyArray}: + # C's arrays are broken beyond repair: + genTraverseProc(c, "a".toRope, typ.sons[0]) + else: + genTraverseProc(c, "(*a)".toRope, typ.sons[0]) let generatedProc = ropef("$1 {$n$2$3$4}$n", [header, p.s[cpsLocals], p.s[cpsInit], p.s[cpsStmts]]) diff --git a/compiler/types.nim b/compiler/types.nim index 5f7496fc0..efdc30dbf 100755 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -866,9 +866,11 @@ proc typeAllowedAux(marker: var TIntSet, typ: PType, kind: TSymKind): bool = of tyArray: result = t.sons[1].kind == tyEmpty or typeAllowedAux(marker, t.sons[1], skVar) - of tyPtr, tyRef: + of tyRef: if kind == skConst: return false result = typeAllowedAux(marker, t.sons[0], skVar) + of tyPtr: + result = typeAllowedAux(marker, t.sons[0], skVar) of tyArrayConstr, tyTuple, tySet, tyConst, tyMutable, tyIter, tyProxy: for i in countup(0, sonsLen(t) - 1): result = typeAllowedAux(marker, t.sons[i], kind) diff --git a/tests/reject/t99bott.nim b/tests/reject/t99bott.nim index 7d11ba4b0..7ebfd61e9 100755 --- a/tests/reject/t99bott.nim +++ b/tests/reject/t99bott.nim @@ -1,7 +1,7 @@ discard """ file: "t99bott.nim" line: 26 - errormsg: "cannot evaluate 'GetBottleNumber(bn)'" + errormsg: "constant expression expected" disabled: false """ ## 99 Bottles of Beer diff --git a/tests/reject/tenumitems.nim b/tests/reject/tenumitems.nim index a0497fd59..b6eee5ba8 100644 --- a/tests/reject/tenumitems.nim +++ b/tests/reject/tenumitems.nim @@ -1,6 +1,6 @@ discard """ line: 7 - errormsg: "a type has no value" + errormsg: "type mismatch" """ type a = enum b,c,d -- cgit 1.4.1-2-gfad0