mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 20:17:42 +00:00
fixes #12334 `nkHiddenStdConv` shouldn't be removed if the sources aren't literals, viz. constant symbols.
This commit is contained in:
@@ -339,6 +339,8 @@ proc fitRemoveHiddenConv(c: PContext, typ: PType, n: PNode): PNode =
|
||||
result.typ = typ
|
||||
if not floatRangeCheck(result.floatVal, typ):
|
||||
localError(c.config, n.info, errFloatToString % [$result.floatVal, typeToString(typ)])
|
||||
elif r1.kind == nkSym and typ.skipTypes(abstractRange).kind == tyCstring:
|
||||
discard "keep nkHiddenStdConv for cstring conversions"
|
||||
else:
|
||||
changeType(c, r1, typ, check=true)
|
||||
result = r1
|
||||
|
||||
@@ -42,6 +42,16 @@ template main() =
|
||||
discard (x, increment, a)
|
||||
mytemp()
|
||||
|
||||
block: # bug #12334
|
||||
block:
|
||||
const b: cstring = "foo"
|
||||
var c = b
|
||||
doAssert c == "foo"
|
||||
block:
|
||||
const a = "foo"
|
||||
const b: cstring = a
|
||||
var c = b
|
||||
doAssert c == "foo"
|
||||
|
||||
|
||||
static: main()
|
||||
|
||||
Reference in New Issue
Block a user