Do not emit object definition it if used only by ref or ptr
This commit is contained in:
parent
a9f21cffdf
commit
70b28a39fe
4 changed files with 32 additions and 1 deletions
12
tests/ccgbugs/mymodule.nim
Normal file
12
tests/ccgbugs/mymodule.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
type
|
||||
MyRefObject* = ref object
|
||||
s: string
|
||||
|
||||
|
||||
proc newMyRefObject*(s: string): MyRefObject =
|
||||
new(result)
|
||||
result.s = s
|
||||
|
||||
proc `$`*(o: MyRefObject): string =
|
||||
o.s
|
||||
|
||||
15
tests/ccgbugs/tforward_decl_only.nim
Normal file
15
tests/ccgbugs/tforward_decl_only.nim
Normal file
|
|
@ -0,0 +1,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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue