mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fix #5648
This commit is contained in:
@@ -135,7 +135,9 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
|
||||
let isCall = ord(n.kind in nkCallKinds+{nkBracketExpr})
|
||||
let n = if n[0].kind == nkBracket: n[0] else: n
|
||||
checkMinSonsLen(n, 1)
|
||||
var base = semTypeNode(c, n.lastSon, nil).skipTypes({tyTypeDesc})
|
||||
var t = semTypeNode(c, n.lastSon, nil)
|
||||
if t.kind == tyTypeDesc and tfUnresolved notin t.flags:
|
||||
t = t.base
|
||||
result = newOrPrevType(kind, prev, c)
|
||||
var isNilable = false
|
||||
# check every except the last is an object:
|
||||
@@ -149,7 +151,7 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
|
||||
tyError, tyObject}:
|
||||
message n[i].info, errGenerated, "region needs to be an object type"
|
||||
addSonSkipIntLit(result, region)
|
||||
addSonSkipIntLit(result, base)
|
||||
addSonSkipIntLit(result, t)
|
||||
#if not isNilable: result.flags.incl tfNotNil
|
||||
|
||||
proc semVarType(c: PContext, n: PNode, prev: PType): PType =
|
||||
|
||||
21
tests/types/t5648.nim
Normal file
21
tests/types/t5648.nim
Normal file
@@ -0,0 +1,21 @@
|
||||
discard """
|
||||
output: "ptr Foo"
|
||||
"""
|
||||
|
||||
import typetraits
|
||||
|
||||
type Foo = object
|
||||
bar*: int
|
||||
|
||||
proc main() =
|
||||
var f = create(Foo)
|
||||
f.bar = 3
|
||||
echo f.type.name
|
||||
|
||||
discard realloc(f, 0)
|
||||
|
||||
var g = Foo()
|
||||
g.bar = 3
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user