fixes #12703; nim cpp rejects valid code would lose const qualifier for cstring to string via cstrToNimstr (#23371)

fixes #12703
ref #19588
This commit is contained in:
ringabout
2024-03-06 01:06:58 +08:00
committed by GitHub
parent d373d304ff
commit 7cd3d60683
2 changed files with 29 additions and 4 deletions

View File

@@ -59,3 +59,17 @@ block: # bug #10219
var v1 = initVector[int](10)
doAssert v1[0] == 0
block: # bug #12703 bug #19588
type
cstringConstImpl {.importc:"const char*".} = cstring
constChar = distinct cstringConstImpl
{.emit: """
const char* foo() {
return "hello";
}
""".}
proc foo(): constChar {.importcpp.} # change to importcpp for C++ backend
doAssert $(foo().cstring) == "hello"