# partial_eval_dead_code

URL: /kida/api/compiler/partial_eval_dead_code/
Section: compiler
Description: Const-only dead-code elimination for parsed template ASTs.

---

> For a complete page index, fetch /kida/llms.txt.

Open LLM text
(/kida/api/compiler/partial_eval_dead_code/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcompiler%2Fpartial_eval_dead_code%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcompiler%2Fpartial_eval_dead_code%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcompiler%2Fpartial_eval_dead_code%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcompiler%2Fpartial_eval_dead_code%2Findex.txt)

Module

#
`compiler.partial_eval_dead_code`

Const-only dead-code elimination for parsed template ASTs.

5Functions

## Functions

`body_has_scoping_nodes`

1

`bool`

▼

Return whether a body contains block-scoped assignment nodes.

`def body_has_scoping_nodes(nodes: Sequence[Node]) -> bool`

##### Parameters

Name
Type
Description

`nodes`
`Sequence[Node]`

##### Returns

`bool`

`_transform_if`

1

`Node | None`

▼

Eliminate dead branches when the test is const-only resolvable.

`def _transform_if(node: If) -> Node | None`

##### Parameters

Name
Type
Description

`node`
`If`

##### Returns

`Node | None`

`_transform_match`

1

`Node | None`

▼

Eliminate dead match/case branches for constant subjects.

`def _transform_match(node: Match) -> Node | None`

##### Parameters

Name
Type
Description

`node`
`Match`

##### Returns

`Node | None`

`_transform_body`

1

`Sequence[Node]`

▼

Eliminate dead nodes and flatten immediate branch replacements.

`def _transform_body(body: Sequence[Node]) -> Sequence[Node]`

##### Parameters

Name
Type
Description

`body`
`Sequence[Node]`

##### Returns

`Sequence[Node]`

`eliminate_dead_code`

1

`Template`

▼

Remove branches whose conditions are provably constant.

Runs without static co…

`def eliminate_dead_code(template: Template) -> Template`

Remove branches whose conditions are provably constant.

Runs without static context and preserves branch structure whenever
inlining would change block-scoping behavior.

##### Parameters

Name
Type
Description

`template`
`Template`

##### Returns

`Template`
