This commit is contained in:
Araq
2015-02-09 13:26:29 +01:00
parent 247af96b00
commit e371bb3e26
4 changed files with 15 additions and 4 deletions

View File

@@ -688,9 +688,6 @@ proc track(tracked: PEffects, n: PNode) =
initVar(tracked, child.sons[i], volatileCheck=false)
addAsgnFact(tracked.guards, child.sons[i], last)
notNilCheck(tracked, last, child.sons[i].typ)
#if last.kind != nkEmpty:
# prevent the all too common 'var x = int' bug: XXX
# since 'var (a, b): T = ()' is not even allowed, there is always type
# inference for (a, b) and thus no nil checking is necessary.
of nkCaseStmt: trackCase(tracked, n)

View File

@@ -359,6 +359,10 @@ 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})
if def.typ.kind == tyTypeDesc and c.p.owner.kind != skMacro:
# prevent the all too common 'var x = int' bug:
localError(def.info, "'typedesc' metatype is not valid here; typed '=' instead of ':'?")
def.typ = errorType(c)
if typ != nil:
if typ.isMetaType:
def = inferWithMetatype(c, typ, def)

View File

@@ -0,0 +1,11 @@
discard """
errormsg: "'typedesc' metatype is not valid here; typed '=' instead of ':'?"
"""
var x = int
echo x

View File

@@ -5,7 +5,6 @@ version 0.10.4
- improve GC-unsafety warnings
- get rid of 'mget'; aka priority of 'var' needs to be 'var{lvalue}'
- improve documentation (theindex!)
- fix the getUniqueType() bug
version 1.0