diff --git a/src/Psalm/Checker/FileChecker.php b/src/Psalm/Checker/FileChecker.php
index <HASH>..<HASH> 100644
--- a/src/Psalm/Checker/FileChecker.php
+++ b/src/Psalm/Checker/FileChecker.php
@@ -212,7 +212,8 @@ class FileChecker implements StatementsSource
             if ($stmt instanceof PhpParser\Node\Stmt\Class_
                 || $stmt instanceof PhpParser\Node\Stmt\Interface_
                 || $stmt instanceof PhpParser\Node\Stmt\Trait_
-                || $stmt instanceof PhpParser\Node\Stmt\Namespace_
+                || ($stmt instanceof PhpParser\Node\Stmt\Namespace_ &&
+                    $stmt->name instanceof PhpParser\Node\Name)
                 || $stmt instanceof PhpParser\Node\Stmt\Function_
             ) {
                 if ($leftover_stmts) {
Make sure we only checking namespaces with names