Expand tyAlias in typeToString (#8634)

Fixes #8339
This commit is contained in:
LemonBoy 2018-08-18 15:27:47 +02:00 • committed by Andreas Rumpf
commit b5171f57ef
2 changed files with 10 additions and 0 deletions

View file

@ -426,6 +426,8 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
sfAnon notin t.sym.flags:
if t.kind == tyInt and isIntLit(t):
result = t.sym.name.s & " literal(" & $t.n.intVal & ")"
elif t.kind == tyAlias:
result = typeToString(t.sons[0])
elif prefer in {preferName, preferTypeName} or t.sym.owner.isNil:
result = t.sym.name.s
if t.kind == tyGenericParam and t.sonsLen > 0:

8
tests/errmsgs/t8339.nim Normal file
View file

@ -0,0 +1,8 @@
discard """
line: 8
errormsg: "type mismatch: got <seq[int]> but expected 'seq[float]'"
"""
import sequtils
var x: seq[float] = @[1].mapIt(it)