---
title: "CAS_RESULT_STRUCTS: constant in Types, TypeShade API"
description: "CAS_RESULT_STRUCTS, a constant in Types. The struct atomicCompareExchangeWeak answers: the contents the location held before the call…"
url: https://typeshade.dev/api/casresultstructs/
language: en
---

# `CAS_RESULT_STRUCTS`

Constant in Types

The struct `atomicCompareExchangeWeak` answers: the contents the location held before the call, and whether the exchange happened.

`import { CAS_RESULT_STRUCTS } from 'typeshade/core/ir'`

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
const CAS_RESULT_STRUCTS: readonly { readonly name: string; readonly fields: readonly { readonly name: string; readonly type: ShaderType; }[]; }[]
```

## Description

WGSL calls the type `__atomic_compare_exchange_result<T>` and gives no way to write that name — measured on Tint, a variable declared with it is “invalid type for variable declaration” — so the result is bound by inference and its fields read.

It is a struct the IR types and no backend declares: WGSL’s is built in, so emitting a `struct` for it would shadow the builtin one, and the emitted code never names the type (`let r = atomicCompareExchangeWeak(&x, a, b);` infers it). That is why these two decls are constants here rather than entries in a module’s `structs`.

## Source

[`src/core/ir/types/cas-result.ts`, line 16](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/types/cas-result.ts#L16), at commit af54ddad5
