Files
Nim/tests/ccgbugs/tforward_decl_only.nim
ringabout 379299a5ac fixes #22286; enforce Non-var T destructors by nimPreviewNonVarDestructor (#22975)
fixes #22286
ref https://forum.nim-lang.org/t/10642

For backwards compatibilities, we might need to keep the changes under a
preview compiler flag. Let's see how many packags it break.

**TODO** in the following PRs

- [ ] Turn the `var T` destructors warning into an error with
`nimPreviewNonVarDestructor`

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2023-11-25 18:27:27 +01:00

35 lines
614 B
Nim

discard """
ccodecheck: "\\i !@('struct tyObject_MyRefObject'[0-z]+' _')"
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)