                     if !function.hasReturnStep { return nil }
                     let returnValue = value(function.returnStep, in: stack)
                     if let returnFunction = returnValue as? Function {
-                        return { self.run(function: returnFunction, symbols: symbols, stack: stack + [Runtime(arguments: $0)], callStack: callStack + [function.steps.count]) }
+                        return { self.run(function: returnFunction, symbols: symbols, stack: stack + [Runtime(arguments: $0)], codePath: DecoderRuntime.codePath(for: function.returnStep, in: codePath)) }
                     } else {
                         return returnValue
                     }

            case .function(let functionType):
                output.append("            case .\(name)(let a):\n")
                for (i, type) in ([name] + functionType.argumentTypes).enumerated() {
                    output.append("                try check(a.o\(i + 1), with: .\(type)Type, function: function, stack: stack, callStack: callStack)\n")
                }
                if let type = functionType.returnType {
                    output.append("                runtime.results[i] = .\(type)Type\n")

                    }
                }
                
                private func typecheck(stack: [TypecheckRuntime], codePath: IndexPath, callStack: IndexPath) throws {
                    let runtime = stack.last!
                    for (i, step) in runtime.function.steps.enumerated() {
                        let callStack = callStack.appending(i)
                        guard let producer = step.producer else { throw DecodeError(cause: .invalidFormat, stack: callStack) }
                        switch producer {
