fix #18410 (Errors initializing an object of RootObj with the C++ backend) [backport] (#18836)

* fix #18410

* one line comment

* typo

* typo

* cover cpp

(cherry picked from commit 2f730afe9e)
This commit is contained in:
flywind
2021-10-31 13:22:00 +08:00
committed by narimiran
parent 97286db546
commit 233c6e9fb3
3 changed files with 19 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
discard """
output: '''@[(s1: "333", s2: ""), (s1: "abc", s2: "def"), (s1: "3x", s2: ""), (s1: "3x", s2: ""), (s1: "3x", s2: ""), (s1: "3x", s2: ""), (s1: "lastone", s2: "")]'''
cmd: "nim c --gc:arc $file"
matrix: "--gc:arc"
targets: "c cpp"
"""
# bug #13240

15
tests/cpp/torc.nim Normal file
View File

@@ -0,0 +1,15 @@
discard """
targets: "cpp"
matrix: "--gc:orc"
"""
import std/options
# bug #18410
type
O = object of RootObj
val: pointer
proc p(): Option[O] = none(O)
doAssert $p() == "none(O)"