fixes #1131
This commit is contained in:
parent
247af96b00
commit
e371bb3e26
4 changed files with 15 additions and 4 deletions
|
|
@ -688,9 +688,6 @@ proc track(tracked: PEffects, n: PNode) =
|
||||||
initVar(tracked, child.sons[i], volatileCheck=false)
|
initVar(tracked, child.sons[i], volatileCheck=false)
|
||||||
addAsgnFact(tracked.guards, child.sons[i], last)
|
addAsgnFact(tracked.guards, child.sons[i], last)
|
||||||
notNilCheck(tracked, last, child.sons[i].typ)
|
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
|
# since 'var (a, b): T = ()' is not even allowed, there is always type
|
||||||
# inference for (a, b) and thus no nil checking is necessary.
|
# inference for (a, b) and thus no nil checking is necessary.
|
||||||
of nkCaseStmt: trackCase(tracked, n)
|
of nkCaseStmt: trackCase(tracked, n)
|
||||||
|
|
|
||||||
|
|
@ -359,6 +359,10 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
var def: PNode
|
var def: PNode
|
||||||
if a.sons[length-1].kind != nkEmpty:
|
if a.sons[length-1].kind != nkEmpty:
|
||||||
def = semExprWithType(c, a.sons[length-1], {efAllowDestructor})
|
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 != nil:
|
||||||
if typ.isMetaType:
|
if typ.isMetaType:
|
||||||
def = inferWithMetatype(c, typ, def)
|
def = inferWithMetatype(c, typ, def)
|
||||||
|
|
|
||||||
11
tests/metatype/typedesc_as_value.nim
Normal file
11
tests/metatype/typedesc_as_value.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "'typedesc' metatype is not valid here; typed '=' instead of ':'?"
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
var x = int
|
||||||
|
|
||||||
|
echo x
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
1
todo.txt
1
todo.txt
|
|
@ -5,7 +5,6 @@ version 0.10.4
|
||||||
- improve GC-unsafety warnings
|
- improve GC-unsafety warnings
|
||||||
- get rid of 'mget'; aka priority of 'var' needs to be 'var{lvalue}'
|
- get rid of 'mget'; aka priority of 'var' needs to be 'var{lvalue}'
|
||||||
- improve documentation (theindex!)
|
- improve documentation (theindex!)
|
||||||
- fix the getUniqueType() bug
|
|
||||||
|
|
||||||
|
|
||||||
version 1.0
|
version 1.0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue