diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/sempass2.nim | 3 | ||||
-rw-r--r-- | compiler/semstmts.nim | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index b36103d9e..ede556a70 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -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) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 6e5b272de..07cae5d04 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -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) |