summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/sempass2.nim3
-rw-r--r--compiler/semstmts.nim4
-rw-r--r--tests/metatype/typedesc_as_value.nim11
-rw-r--r--todo.txt1
4 files changed, 15 insertions, 4 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)
diff --git a/tests/metatype/typedesc_as_value.nim b/tests/metatype/typedesc_as_value.nim
new file mode 100644
index 000000000..f6e526987
--- /dev/null
+++ b/tests/metatype/typedesc_as_value.nim
@@ -0,0 +1,11 @@
+discard """
+  errormsg: "'typedesc' metatype is not valid here; typed '=' instead of ':'?"
+"""
+
+
+var x = int
+
+echo x
+
+
+
diff --git a/todo.txt b/todo.txt
index 252699bf1..fca43ad11 100644
--- a/todo.txt
+++ b/todo.txt
@@ -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