Properly wrap discarded statements (#10322)
Failing to do so lead the codegen to emit invalid code sometimes, especially when C++ references were involved. Fixes #10241
This commit is contained in:
parent
52a54f5f04
commit
15584879b9
3 changed files with 35 additions and 12 deletions
19
tests/cpp/t10241.nim
Normal file
19
tests/cpp/t10241.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
discard """
|
||||
targets: "cpp"
|
||||
action: "compile"
|
||||
"""
|
||||
|
||||
type
|
||||
String* {.importcpp: "std::string", header: "string".} = object
|
||||
|
||||
proc initString*(): String
|
||||
{.importcpp: "std::string()", header: "string".}
|
||||
|
||||
proc append*(this: var String, str: String): var String
|
||||
{.importcpp: "append", header: "string", discardable.}
|
||||
|
||||
var
|
||||
s1 = initString()
|
||||
s2 = initString()
|
||||
|
||||
s1.append s2
|
||||
Loading…
Add table
Add a link
Reference in a new issue