diff options
author | skilchen <skilchen@users.noreply.github.com> | 2018-07-30 10:41:59 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-07-30 10:41:59 +0200 |
commit | becb6743f8197f53897cef1b2fda97f1784f961c (patch) | |
tree | 59aa6f19f634a492b884a355395573095fd77dde | |
parent | 06571f5495fd48ee1b98873d92c3506ff2b9d6b0 (diff) | |
download | Nim-becb6743f8197f53897cef1b2fda97f1784f961c.tar.gz |
fixes #8434 (incomplete info in errmsg about 'required type') (#8441)
-rw-r--r-- | compiler/types.nim | 10 | ||||
-rw-r--r-- | tests/errmsgs/t8434.nim | 16 |
2 files changed, 24 insertions, 2 deletions
diff --git a/compiler/types.nim b/compiler/types.nim index 4180d34a7..23fbc9f1b 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -496,9 +496,15 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string = add(result, typeToString(t.sons[i])) result.add "]" of tyAnd: - result = typeToString(t.sons[0]) & " and " & typeToString(t.sons[1]) + for i, son in t.sons: + result.add(typeToString(son)) + if i < t.sons.high: + result.add(" and ") of tyOr: - result = typeToString(t.sons[0]) & " or " & typeToString(t.sons[1]) + for i, son in t.sons: + result.add(typeToString(son)) + if i < t.sons.high: + result.add(" or ") of tyNot: result = "not " & typeToString(t.sons[0]) of tyExpr: diff --git a/tests/errmsgs/t8434.nim b/tests/errmsgs/t8434.nim new file mode 100644 index 000000000..60fe2e2df --- /dev/null +++ b/tests/errmsgs/t8434.nim @@ -0,0 +1,16 @@ +discard """ + errormsg: "type mismatch: got <byte, int literal(0)>" + nimout: '''but expected one of: +proc fun0[T1: int | float | + object | array | seq](a1: T1; a2: int) + first type mismatch at position: 1 + required type: T1: int or float or object or array or seq + but expression 'byte(1)' is of type: byte + +expression: fun0(byte(1), 0) +''' +""" + +proc fun0[T1:int|float|object|array|seq](a1:T1, a2:int)=discard + +fun0(byte(1), 0) |