 
       let selfSym: Symbol? = node.innerScope?.symbols["self"]?[0]
       if node.kind == .constructor {
-        guard selfSym != nil
-          else { fatalError("no symbol for 'self' in constructor scope") }
+        assert(selfSym != nil, "missing symbol for 'self' in constructor")
         locals.top![selfSym!] = builder.buildAlloc(type: fnTy.codomain, id: 0)
+      } else if node.symbol!.isMethod {
+        assert(selfSym != nil, "missing symbol for 'self' in method")
+        locals.top![selfSym!] = AIRParameter(
+          type: builder.unit.getType(of: selfSym!.type!),
+          id: builder.currentBlock!.nextRegisterID())
       }
 
       // Create the function parameters.

      // Note that arguments are captured by reference in the current frame.
      locals.top![node.symbol!] = builder.buildPartialApply(
        function: fn,
        arguments: node.captures
          .sorted(by: { a, b in a.name < b.name })
          .map({ locals.top![$0]! }),
        type: fnTy)
    }


  public func visit(_ node: FunDecl) throws {
    // Get the type of the declared function.
    var fnTy = builder.unit.getFunctionType(of: node.type! as! FunctionType)

    // Constructors and methods shall not have closures.
    assert(
      node.captures.isEmpty || (node.kind != .constructor && node.kind != .method),
      "constructor and methods shall not have closures")

    if node.symbol!.isMethod {
      // Methods (and destructors?) are static functions that take the self symbol and return the
      // "actual" method as a closure.
      let symbols = node.innerScope!.symbols["self"]!
      assert(symbols.count == 1)
      let methTy = fnTy.codomain as! AIRFunctionType
      fnTy = builder.unit.getFunctionType(
        from: [builder.unit.getType(of: symbols[0].type!)] + methTy.domain,
        to: methTy.codomain)
    } else if !node.captures.isEmpty {
      // If the function captures symbols, we need to emit a context-free version of the it, which
      // gets the captured values as parameters. This boils down to extending the domain.
      let additional = node.captures.map { builder.unit.getType(of: $0.type!) }
      fnTy = builder.unit.getFunctionType(from: additional + fnTy.domain, to: fnTy.codomain)
    }

