summary refs log blame commit diff stats
path: root/tests/ccgbugs/tforward_decl_only.nim
blob: 2a867bc3bec198f7eb90adc68025ec7806b36544 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                                             













                                                          




                     
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)