---
title: "Rule 8.2: Functions and entry points in TypeShade"
description: "Rule 8.2 of the TypeShade language design, in Functions and entry points."
url: https://typeshade.dev/reference/rules/8-2/
language: en
---

# Rule 8.2

Chapter 8, Functions and entry points Test

A vertex entry must return the position, as a bare `vec4` or as a struct with a `builtin<"position">` field; a fragment entry returns one value at location 0, a struct of render targets, or nothing. The decorated field, `@builtin("position")`, stays accepted until the release after the migration release (change 0111, D5).

The rule text and the parts under it are the compiler's own English, as the design document writes them.

## Rationale

nothing can invent a position, and WGSL says so.

## Derives from

[Restrictions on Functions](https://gpuweb.github.io/gpuweb/wgsl/#function-restriction) (“a vertex shader must return the position built-in output value”); change `0111` in `changes/` (D2); change `0135`; surface §3.

## How it is verified

Checked by a test. A test, a gate script or a CI workflow names this rule, and the traceability check fails when a file listed below stops naming it.

Where the rule says the compiler enforces it:

`src/compiler/ts/entry-io.test.ts`; `src/compiler/ts/attribute-types.test.ts` for the position written as a type.

The files that verify it at commit af54ddad5, each at the first line that names the rule:

- [`src/compiler/ts/attribute-types.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/attribute-types.test.ts#L1)
- [`src/compiler/ts/builtin-type-diagnostic.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/builtin-type-diagnostic.test.ts#L1)
- [`src/compiler/ts/entry-io.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/entry-io.test.ts#L1)
- [`src/compiler/ts/entry-locations.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/entry-locations.test.ts#L1)
- [`src/compiler/ts/io-attribute-arguments.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/io-attribute-arguments.test.ts#L1)

## Explained in

The sections of the surface document that explain this rule, at commit af54ddad5:

- [§3 Entries — stage attributes and explicit builtins](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#3-entries--stage-attributes-and-explicit-builtins)

## See also

- [Rule 8.1](https://typeshade.dev/reference/rules/8-1/) Test
- [Rule 8.3](https://typeshade.dev/reference/rules/8-3/) Test
- [Design rules](https://typeshade.dev/reference/rules/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

The rule at commit af54ddad5:

- [`docs/language-design.md:786`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L786) (the design document)
- [`reqs/rules/RULE-0802.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-0802.md) (its traceability item)
