File: tforward_decl_only.nim

package info (click to toggle)
nim 0.19.4-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 462,356 kB
  • sloc: sh: 11,089; ansic: 4,699; makefile: 706; python: 309; sql: 297; asm: 141; xml: 13
file content (34 lines) | stat: -rw-r--r-- 614 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)