* fix #15910 * produce op of op is nil * Trigger build
This commit is contained in:
parent
fc735e4b08
commit
a4d02f591c
2 changed files with 77 additions and 5 deletions
|
|
@ -4,6 +4,21 @@ discard """
|
|||
hello
|
||||
hello
|
||||
@["a", "b"]
|
||||
---------------------
|
||||
plain:
|
||||
destroying: ('first', 42)
|
||||
destroying: ('second', 20)
|
||||
destroying: ('third', 12)
|
||||
|
||||
Option[T]:
|
||||
destroying: ('first', 42)
|
||||
destroying: ('second', 20)
|
||||
destroying: ('third', 12)
|
||||
|
||||
seq[T]:
|
||||
destroying: ('first', 42)
|
||||
destroying: ('second', 20)
|
||||
destroying: ('third', 12)
|
||||
'''
|
||||
"""
|
||||
|
||||
|
|
@ -47,4 +62,53 @@ proc freeJVMObject(o: JVMObject) =
|
|||
proc fromJObject(T: typedesc[JVMObject]): T =
|
||||
result.new(cast[proc(r: T) {.nimcall.}](freeJVMObject))
|
||||
|
||||
discard JVMObject.fromJObject()
|
||||
discard JVMObject.fromJObject()
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Issue #15910
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
import options
|
||||
|
||||
type
|
||||
Thing = object
|
||||
name: string
|
||||
age: int
|
||||
|
||||
proc `=destroy`(thing: var Thing) =
|
||||
if thing.name != "":
|
||||
echo "destroying: ('", thing.name, "', ", thing.age, ")"
|
||||
`=destroy`(thing.name)
|
||||
`=destroy`(thing.age)
|
||||
|
||||
proc plain() =
|
||||
var t = Thing(name: "first", age: 42)
|
||||
t = Thing(name: "second", age: 20)
|
||||
t = Thing()
|
||||
let u = Thing(name: "third", age: 12)
|
||||
|
||||
proc optionT() =
|
||||
var t = Thing(name: "first", age: 42).some
|
||||
t = Thing(name: "second", age: 20).some
|
||||
t = none(Thing)
|
||||
let u = Thing(name: "third", age: 12).some
|
||||
|
||||
proc seqT() =
|
||||
var t = @[Thing(name: "first", age: 42)]
|
||||
t = @[Thing(name: "second", age: 20)]
|
||||
t = @[]
|
||||
let u = @[Thing(name: "third", age: 12)]
|
||||
|
||||
echo "---------------------"
|
||||
echo "plain:"
|
||||
plain()
|
||||
echo()
|
||||
|
||||
echo "Option[T]:"
|
||||
optionT()
|
||||
echo()
|
||||
|
||||
echo "seq[T]:"
|
||||
seqT()
|
||||
echo()
|
||||
Loading…
Add table
Add a link
Reference in a new issue