* fix #15910

* produce op of op is nil

* Trigger build
This commit is contained in:
cooldome 2020-11-16 11:39:28 +00:00 • committed by GitHub
commit a4d02f591c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 77 additions and 5 deletions

View file

@ -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()