---
title: "SD0118: grad cannot differentiate this function in TypeShade"
description: "SD0118, an error code of the TypeShade compiler. grad cannot differentiate this function"
url: https://typeshade.dev/reference/errors/sd0118/
language: en
---

# `SD0118`

Core code

grad cannot differentiate this function

No `"use typeshade"` program on this site raises this code, so the page has no example. The [`fn()`](https://typeshade.dev/api/fn/) builder builds the IR directly and reaches the check at the lines under Source.

The registry text and every compiler message on these pages are the compiler's own English.

## When it fires

`grad` (roadmap 0.7 item 18) differentiates a function's IR in forward mode. A construct it has no derivative rule for is refused by name rather than given a zero derivative, since a silent zero is a wrong answer that looks like a right one.

## How to fix it

The registry's hint: the detail names the construct and what to write instead; grad differentiates `f32`, float-vector and float-matrix arithmetic, the component-wise builtins, if, switch and for, and calls to other functions of the module

## See also

- [`TypeShadeError`](https://typeshade.dev/api/typeshadeerror/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

Where the compiler raises this code at commit af54ddad5, one line per file:

- [`src/core/passes/grad/refusal.ts:4`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/grad/refusal.ts#L4)
