diff options
author | Araq <rumpf_a@web.de> | 2018-10-02 23:45:27 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-10-02 23:45:27 +0200 |
commit | bf8595580227ece7cd8a28365d2147229acff4b9 (patch) | |
tree | 34aeba8437de44f63965996da60716000acb1409 | |
parent | 7ac1e6e52860dd511fdaa2db52f4213c232bf616 (diff) | |
download | Nim-bf8595580227ece7cd8a28365d2147229acff4b9.tar.gz |
fixes #7092
-rw-r--r-- | compiler/ccgexprs.nim | 2 | ||||
-rw-r--r-- | tests/concepts/tusertypeclasses.nim | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index cf5eac56c..2add4a162 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -59,7 +59,7 @@ proc genLiteral(p: BProc, n: PNode, ty: PType): Rope = else: result = rope("NIM_NIL") of nkStrLit..nkTripleStrLit: - case skipTypes(ty, abstractVarRange + {tyStatic}).kind + case skipTypes(ty, abstractVarRange + {tyStatic, tyUserTypeClass, tyUserTypeClassInst}).kind of tyNil: result = genNilStringLiteral(p.module, n.info) of tyString: diff --git a/tests/concepts/tusertypeclasses.nim b/tests/concepts/tusertypeclasses.nim index 533bd528d..3ea10569f 100644 --- a/tests/concepts/tusertypeclasses.nim +++ b/tests/concepts/tusertypeclasses.nim @@ -4,6 +4,7 @@ Sortable Container TObj int +111 111 ''' """ @@ -25,7 +26,7 @@ type C.len is Ordinal for v in items(C): v.type is tuple|object - + proc foo(c: ObjectContainer) = echo "Container" @@ -94,6 +95,15 @@ proc to(x: TObj, t: type JSonValue) = discard proc testFoo(x: TFoo) = echo x.TypeName echo x.MappedType.name - + testFoo(TObj(x: 10)) +# bug #7092 + +type stringTest = concept x + x is string + +let usedToFail: stringTest = "111" +let working: string = "111" + +echo usedToFail, " ", working |