string to string conversion keeps the dest type (#9323)

Fixes #9322
This commit is contained in:
LemonBoy
2018-10-12 08:50:28 +02:00
committed by Andreas Rumpf
parent 9b002e0d4f
commit fab4d38411
2 changed files with 13 additions and 1 deletions

View File

@@ -379,7 +379,7 @@ proc evalOp(m: TMagic, n, a, b, c: PNode; g: ModuleGraph): PNode =
result = newStrNodeT(s, n, g)
else:
result = newStrNodeT(getStrOrChar(a), n, g)
of mStrToStr: result = a
of mStrToStr: result = newStrNodeT(getStrOrChar(a), n, g)
of mEnumToStr: result = newStrNodeT(ordinalValToString(a, g), n, g)
of mArrToSeq:
result = copyTree(a)

12
tests/distinct/t9322.nim Normal file
View File

@@ -0,0 +1,12 @@
discard """
output: apr
"""
type Fix = distinct string
proc `$`(f: Fix): string {.borrow.}
proc mystr(s: string) =
echo s
mystr($Fix("apr"))