Skip to content

Commit

Permalink
attempt to fix nim-lang#5648
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Apr 3, 2017
1 parent dd7ebb2 commit 86a4135
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ 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 base = semTypeNode(c, n.lastSon, nil)
let skippedBase = base.skipTypes({tyTypeDesc})
if skippedBase.kind != tyNone: base = skippedBase

result = newOrPrevType(kind, prev, c)
var isNilable = false
# check every except the last is an object:
Expand Down
16 changes: 16 additions & 0 deletions tests/generics/tgenericreturntype.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
discard """
output: "(fooInt: 13)"
"""

type Foo = object
fooInt*: int

proc createX(T: typedesc): ptr T =
createU(T)

var f = createX(Foo)
f.fooInt = 13
echo f[]



0 comments on commit 86a4135

Please sign in to comment.