From b38c7adad1e153c8678c93098391cb2bd8d8fef6 Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 3 Apr 2011 22:59:00 +0200 Subject: [PATCH] bugfix: GC more forgiving --- lib/pure/htmlparser.nim | 4 ++-- lib/system.nim | 9 +++++---- lib/system/gc.nim | 5 ++++- rod/semtypes.nim | 2 ++ tests/reject/ttypenoval.nim | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/pure/htmlparser.nim b/lib/pure/htmlparser.nim index d84688be60..4136ecf57a 100755 --- a/lib/pure/htmlparser.nim +++ b/lib/pure/htmlparser.nim @@ -333,11 +333,11 @@ proc parse(x: var TXmlParser, errors: var seq[string]): PXmlNode = of xmlElementOpen: result = newElement(x.elementName.toLower) next(x) - result.attr = newStringTable() + result.attrs = newStringTable() while true: case x.kind of xmlAttribute: - result.attr[x.attrKey] = x.attrValue + result.attrs[x.attrKey] = x.attrValue next(x) of xmlElementClose: next(x) diff --git a/lib/system.nim b/lib/system.nim index daf0c5423d..3c31e65cda 100755 --- a/lib/system.nim +++ b/lib/system.nim @@ -1213,14 +1213,14 @@ iterator fieldPairs*(x, y: tuple[]): tuple[a, b: expr] {. ## in the loop body. proc `==`*[T: tuple](x, y: T): bool = - ## generic ``==`` operator that is lifted from the components + ## generic ``==`` operator for tuples that is lifted from the components ## of `x` and `y`. for a, b in fields(x, y): if a != b: return false return true proc `<=`*[T: tuple](x, y: T): bool = - ## generic ``<=`` operator that is lifted from the components + ## generic ``<=`` operator for tuples that is lifted from the components ## of `x` and `y`. This implementation uses `cmp`. for a, b in fields(x, y): var c = cmp(a, b) @@ -1229,7 +1229,7 @@ proc `<=`*[T: tuple](x, y: T): bool = return true proc `<`*[T: tuple](x, y: T): bool = - ## generic ``<`` operator that is lifted from the components + ## generic ``<`` operator for tuples that is lifted from the components ## of `x` and `y`. This implementation uses `cmp`. for a, b in fields(x, y): var c = cmp(a, b) @@ -1238,7 +1238,8 @@ proc `<`*[T: tuple](x, y: T): bool = return false proc `$`*[T: tuple](x: T): string = - ## generic ``$`` operator that is lifted from the components of `x`. + ## generic ``$`` operator for tuples that is lifted from the components + ## of `x`. result = "(" for name, value in fieldPairs(x): if result.len > 1: result.add(", ") diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 5288316f2f..882825f5e9 100755 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -265,7 +265,10 @@ proc unsureAsgnRef(dest: ppointer, src: pointer) {.compilerProc.} = # reference is in the stack or not (this can happen for var parameters). if not IsOnStack(dest): if src != nil: incRef(usrToCell(src)) - if dest^ != nil: decRef(usrToCell(dest^)) + # XXX finally use assembler for the stack checking instead! + # the test for '!= nil' is correct, but I got tired of the segfaults + # resulting from the crappy stack checking: + if cast[int](dest^) >=% PageSize: decRef(usrToCell(dest^)) dest^ = src proc initGC() = diff --git a/rod/semtypes.nim b/rod/semtypes.nim index 79511b716c..38f1ffc71e 100755 --- a/rod/semtypes.nim +++ b/rod/semtypes.nim @@ -694,6 +694,8 @@ proc semGenericParamList(c: PContext, n: PNode, father: PType = nil): PNode = if a.sons[L-2].kind != nkEmpty: typ = newTypeS(tyGenericParam, c) semGenericConstraints(c, a.sons[L-2], typ) + if sonsLen(typ) == 1 and typ.sons[0].kind == tyTypeDesc: + typ = typ.sons[0] elif def.kind != nkEmpty: typ = newTypeS(tyExpr, c) else: typ = nil for j in countup(0, L-3): diff --git a/tests/reject/ttypenoval.nim b/tests/reject/ttypenoval.nim index ed91b05e24..44b3db879f 100755 --- a/tests/reject/ttypenoval.nim +++ b/tests/reject/ttypenoval.nim @@ -1,5 +1,5 @@ discard """ - file: "tambsym.nim" + file: "ttypenoval.nim" line: 36 errormsg: "a type has no value" """