From fab4d38411d8f658a587bb34568fc9ec1887462e Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Fri, 12 Oct 2018 08:50:28 +0200 Subject: [PATCH] string to string conversion keeps the dest type (#9323) Fixes #9322 --- compiler/semfold.nim | 2 +- tests/distinct/t9322.nim | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/distinct/t9322.nim diff --git a/compiler/semfold.nim b/compiler/semfold.nim index 627877cbeb..e977a242ba 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -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) diff --git a/tests/distinct/t9322.nim b/tests/distinct/t9322.nim new file mode 100644 index 0000000000..2501d7fc7a --- /dev/null +++ b/tests/distinct/t9322.nim @@ -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"))