fix #959
Variable declarations using a type class will be subject to type inference similar to the one already present in type coercions and the return type inference.
This commit is contained in:
parent
c7116cc121
commit
9a3963f51b
3 changed files with 27 additions and 6 deletions
|
|
@ -350,9 +350,14 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
|||
var def: PNode
|
||||
if a.sons[length-1].kind != nkEmpty:
|
||||
def = semExprWithType(c, a.sons[length-1], {efAllowDestructor})
|
||||
# BUGFIX: ``fitNode`` is needed here!
|
||||
# check type compability between def.typ and typ:
|
||||
if typ != nil: def = fitNode(c, typ, def)
|
||||
if typ != nil:
|
||||
if typ.isMetaType:
|
||||
def = inferWithMetaType(c, typ, def)
|
||||
typ = def.typ
|
||||
else:
|
||||
# BUGFIX: ``fitNode`` is needed here!
|
||||
# check type compability between def.typ and typ
|
||||
def = fitNode(c, typ, def)
|
||||
else:
|
||||
typ = skipIntLit(def.typ)
|
||||
if typ.kind in {tySequence, tyArray, tySet} and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue