better typeToString; fixes #340
This commit is contained in:
parent
1342798cc7
commit
45c9975e9c
2 changed files with 16 additions and 15 deletions
|
|
@ -336,6 +336,9 @@ proc instFieldLoopBody(c: TFieldInstCtx, n: PNode, forLoop: PNode): PNode =
|
||||||
result.add(newSymNode(c.field, n.info))
|
result.add(newSymNode(c.field, n.info))
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
if n.kind == nkContinueStmt:
|
||||||
|
localError(n.info, errGenerated,
|
||||||
|
"'continue' not supported in a 'fields' loop")
|
||||||
result = copyNode(n)
|
result = copyNode(n)
|
||||||
newSons(result, sonsLen(n))
|
newSons(result, sonsLen(n))
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in countup(0, sonsLen(n)-1):
|
||||||
|
|
|
||||||
|
|
@ -406,16 +406,11 @@ const
|
||||||
"bignum", "const ",
|
"bignum", "const ",
|
||||||
"!", "varargs[$1]", "iter[$1]", "Error Type", "TypeClass"]
|
"!", "varargs[$1]", "iter[$1]", "Error Type", "TypeClass"]
|
||||||
|
|
||||||
proc constraintsToStr(t: PType): string =
|
|
||||||
proc consToStr(t: PType): string =
|
proc consToStr(t: PType): string =
|
||||||
if t.len > 0: result = t.typeToString
|
if t.len > 0: result = t.typeToString
|
||||||
else: result = typeToStr[t.kind].strip
|
else: result = typeToStr[t.kind].strip
|
||||||
|
|
||||||
# better error messages are nice:
|
proc constraintsToStr(t: PType): string =
|
||||||
case t.len
|
|
||||||
of 0: result = "constraint[]"
|
|
||||||
of 1: result = "constraint[" & consToStr(t.sons[0]) & "]"
|
|
||||||
else:
|
|
||||||
let sep = if tfAny in t.flags: " or " else: " and "
|
let sep = if tfAny in t.flags: " or " else: " and "
|
||||||
result = ""
|
result = ""
|
||||||
for i in countup(0, t.len - 1):
|
for i in countup(0, t.len - 1):
|
||||||
|
|
@ -446,7 +441,10 @@ proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
|
||||||
if t.len == 0: result = "typedesc"
|
if t.len == 0: result = "typedesc"
|
||||||
else: result = "typedesc[" & constraintsToStr(t) & "]"
|
else: result = "typedesc[" & constraintsToStr(t) & "]"
|
||||||
of tyTypeClass:
|
of tyTypeClass:
|
||||||
result = constraintsToStr(t)
|
case t.len
|
||||||
|
of 0: result = "typeclass[]"
|
||||||
|
of 1: result = "typeclass[" & consToStr(t.sons[0]) & "]"
|
||||||
|
else: result = constraintsToStr(t)
|
||||||
of tyExpr:
|
of tyExpr:
|
||||||
if t.len == 0: result = "expr"
|
if t.len == 0: result = "expr"
|
||||||
else: result = "expr[" & constraintsToStr(t) & "]"
|
else: result = "expr[" & constraintsToStr(t) & "]"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue