Nim/tests/ccgbugs/tforward_decl_only.nim
ringabout a70d3abd37
replace data init function with consts for typeinfov2 (#20977)
* replace data initial function with consts for typeinfov2

* fixes

* fixes

* workaround C++

* C++ keeps the previous implementaion

* fixes
2022-12-01 13:29:58 +01:00

35 lines
651 B
Nim

discard """
ccodecheck: "\\i !@('struct tyObject_MyRefObject'[0-z]+' {')"
ccodecheck: "\\i !@('mymoduleInit')"
output: "hello"
"""
# issue #7339
# Test that MyRefObject is only forward declared as it used only by reference
import mymodule
type AnotherType = object
f: MyRefObject
let x = AnotherType(f: newMyRefObject("hello"))
echo $x.f
# bug #7363
type
Foo = object
a: cint
Foo2 = object
b: cint
proc f(foo: ptr Foo, foo2: ptr Foo2): cint =
if foo != nil: {.emit: "`result` = `foo`->a;".}
if foo2 != nil: {.emit: [result, " = ", foo2[], ".b;"].}
discard f(nil, nil)
# bug #7392
var x1: BaseObj
var x2 = ChildObj(x1)