tforward_decl_only.nim 690 B

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