diff options
author | PMunch <peterme@peterme.net> | 2020-04-27 18:43:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-27 18:43:02 +0200 |
commit | 0e6eb96a5f5fc2eb6c310a19b5f522c9b811de29 (patch) | |
tree | b48c110a7659780dc6d5d53c40f31f63c0f1cddf | |
parent | bb982c644b8e3e8a59cf2c60b28ff91741c7dc9b (diff) | |
download | Nim-0e6eb96a5f5fc2eb6c310a19b5f522c9b811de29.tar.gz |
Fix #14066 issue with stringifying incomplete types (#14135)
-rw-r--r-- | compiler/types.nim | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/compiler/types.nim b/compiler/types.nim index b75a97c25..cf3f7117a 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -589,27 +589,41 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string = else: result = "typeof(" & renderTree(t.n) & ")" of tyArray: - if t[0].kind == tyRange: - result = "array[" & rangeToStr(t[0].n) & ", " & - typeToString(t[1]) & ']' - else: - result = "array[" & typeToString(t[0]) & ", " & - typeToString(t[1]) & ']' + result = "array" + if t.len > 0: + if t[0].kind == tyRange: + result &= "[" & rangeToStr(t[0].n) & ", " & + typeToString(t[1]) & ']' + else: + result &= "[" & typeToString(t[0]) & ", " & + typeToString(t[1]) & ']' of tyUncheckedArray: - result = "UncheckedArray[" & typeToString(t[0]) & ']' + result = "UncheckedArray" + if t.len > 0: + result &= "[" & typeToString(t[0]) & ']' of tySequence: if t.sym != nil and prefer != preferResolved: result = t.sym.name.s else: - result = "seq[" & typeToString(t[0]) & ']' + result = "seq" + if t.len > 0: + result &= "[" & typeToString(t[0]) & ']' of tyOpt: - result = "opt[" & typeToString(t[0]) & ']' + result = "opt" + if t.len > 0: + result &= "opt[" & typeToString(t[0]) & ']' of tyOrdinal: - result = "ordinal[" & typeToString(t[0]) & ']' + result = "ordinal" + if t.len > 0: + result &= "[" & typeToString(t[0]) & ']' of tySet: - result = "set[" & typeToString(t[0]) & ']' + result = "set" + if t.len > 0: + result &= "[" & typeToString(t[0]) & ']' of tyOpenArray: - result = "openArray[" & typeToString(t[0]) & ']' + result = "openArray" + if t.len > 0: + result &= "[" & typeToString(t[0]) & ']' of tyDistinct: result = "distinct " & typeToString(t[0], if prefer == preferModuleInfo: preferModuleInfo else: preferTypeName) @@ -624,7 +638,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string = if i < t.n.len - 1: result.add(", ") result.add(']') elif t.len == 0: - result = "tuple[]" + result = "tuple" else: if prefer == preferTypeName: result = "(" else: result = "tuple of (" |