mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
[isolation]fix empty ref object bug (#17471)
* fix nim js cmp fails at CT * [Minor]fix empty ref object for isolation * Update compiler/isolation_check.nim * Update compiler/isolation_check.nim Co-authored-by: Clyybber <darkmine956@gmail.com> Co-authored-by: Clyybber <darkmine956@gmail.com>
This commit is contained in:
@@ -100,7 +100,12 @@ proc checkIsolate*(n: PNode): bool =
|
||||
for it in n:
|
||||
result = checkIsolate(it.lastSon)
|
||||
if not result: break
|
||||
of nkCaseStmt, nkObjConstr:
|
||||
of nkCaseStmt:
|
||||
for i in 1..<n.len:
|
||||
result = checkIsolate(n[i].lastSon)
|
||||
if not result: break
|
||||
of nkObjConstr:
|
||||
result = true
|
||||
for i in 1..<n.len:
|
||||
result = checkIsolate(n[i].lastSon)
|
||||
if not result: break
|
||||
@@ -123,4 +128,3 @@ proc checkIsolate*(n: PNode): bool =
|
||||
else:
|
||||
# no ref, no cry:
|
||||
result = true
|
||||
|
||||
|
||||
@@ -8,6 +8,14 @@ import std/[isolation, json]
|
||||
|
||||
|
||||
proc main() =
|
||||
block:
|
||||
type
|
||||
Empty = ref object
|
||||
|
||||
|
||||
var x = isolate(Empty())
|
||||
discard extract(x)
|
||||
|
||||
block: # string literals
|
||||
var data = isolate("string")
|
||||
doAssert data.extract == "string"
|
||||
|
||||
Reference in New Issue
Block a user