tforward_decl_only.nim 614 B

1234567891011121314151617181920212223242526272829303132333435
  1. discard """
  2. ccodecheck: "\\i !@('struct tyObject_MyRefObject'[0-z]+' _')"
  3. output: "hello"
  4. """
  5. # issue #7339
  6. # Test that MyRefObject is only forward declared as it used only by reference
  7. import mymodule
  8. type AnotherType = object
  9. f: MyRefObject
  10. let x = AnotherType(f: newMyRefObject("hello"))
  11. echo $x.f
  12. # bug #7363
  13. type
  14. Foo = object
  15. a: cint
  16. Foo2 = object
  17. b: cint
  18. proc f(foo: ptr Foo, foo2: ptr Foo2): cint =
  19. if foo != nil: {.emit: "`result` = `foo`->a;".}
  20. if foo2 != nil: {.emit: [result, " = ", foo2[], ".b;"].}
  21. discard f(nil, nil)
  22. # bug #7392
  23. var x1: BaseObj
  24. var x2 = ChildObj(x1)