         self.underDeclaration[self.scopes.last] = []
 
         // Add a new symbol for each entity declared within the node's scope.
+        for name in node.symbols {
+            self.scopes.last.add(symbol: Symbol(name: name))
+        }
+
+        // Visit the node's children.
+        try self.traverse(node)
+        self.scopes.pop()
+    }
+
+    public mutating func visit(_ node: Block) throws {
+        // Create a scope for the block.
+        self.scopes.push(Scope(name: "block", parent: self.scopes.last))
+        self.underDeclaration[self.scopes.last] = []
+
+        // Add a new symbol for each entity declared within the block's scope.
         for name in node.symbols {
             self.scopes.last.add(symbol: Symbol(name: name))
         }

        self.underDeclaration[self.scopes.last]?.remove(node.name)
    }

    public mutating func visit(_ node: Ident) throws {
        guard let definingScope = self.scopes.last.findScopeDefining(name: node.name) else {
            throw CompilerError.undefinedSymbol(name: node.name, location: node.location)
        }
        node.scope = definingScope
    }


        //

        // Once we visited the function's signature, we can visit its body.
        for name in (node.body as! Block).symbols {
            if !self.scopes.last.defines(name: name) {
                self.scopes.last.add(symbol: Symbol(name: name))
