---
generated: true
model: claude-opus-4-7
generated_at: 2026-05-22T00:00:00+00:00
source_commit: 6e923e2c0fe3cae4e7cf40e25a96569df5b9f009
watched_paths_digest: 46d545d00112e20974ad7c66196cd74864348c29baa96c46b13ae4a26b395634
source_doc: docs/generated/design/syntax-reference/keywords-and-builtins.md
source_doc_digest: 149c069099bcdbf65d61cb7c0a8efad6ebfce473dad9ffb85251ba6cb96f4820
warning: "Auto-generated. May drift from source. Do not edit by hand."
---

# Tests for syntax-reference/keywords-and-builtins

## Intent
Tests verify the parser-surface behaviors described in
[`docs/generated/design/syntax-reference/keywords-and-builtins.md`](../../../design/syntax-reference/keywords-and-builtins.md):
which identifiers acquire special meaning as statement, decl,
modifier, expression, or core-module-supplied keywords, and how the
documented meaning surfaces when a small program is compiled. Each
test pins a single doc claim and uses the smallest valid program that
makes the claim observable. Most tests are observed through
`//TEST:INTERPRET`; target-dependent keywords (`groupshared`,
`discard`, `gl_*`/`SV_*`, GLSL/HLSL meta-module types) are observed
through text-emit `FileCheck`s on the relevant backends; one negative
test confirms that `let` immutability is enforced by the checker.


## Functional coverage
| Claim | Intent | Anchor | Tests |
| --- | --- | --- | --- |
| `hitAttributeEXT` is a complex modifier in the raytracing family; an HLSL-style intersection shader that calls `ReportHit` with a user-defined hit-attribute struct lowers to GLSL with a `hitAttributeEXT`-decorated variable and pulls in the `GL_EXT_ray_tracing` extension. | expansion | [#complex-modifiers-take-arguments](../../../design/syntax-reference/keywords-and-builtins.md#complex-modifiers-take-arguments) | [`modifier-raytracing-hitattributeext.slang`](modifier-raytracing-hitattributeext.slang) |
| Boundary: HLSL `register(uN)` UAV-binding annotation is part of the HLSL-flavored vocabulary contributed by `hlsl.meta.slang`; it survives into HLSL emit attached to the corresponding buffer. | boundary | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`boundary-register-u0-binding-hlsl.slang`](boundary-register-u0-binding-hlsl.slang) |
| Boundary: `RWStructuredBuffer<T>` from `hlsl.meta.slang` survives into HLSL emit with an `int(0)` indexing expression at the documented lower-edge index. | boundary | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`boundary-rwstructuredbuffer-index-zero-hlsl.slang`](boundary-rwstructuredbuffer-index-zero-hlsl.slang) |
| Boundary: `float4` is the maximum-width vector documented in `core.meta.slang`; the four-component `wzyx` swizzle is the full-length reverse, the largest swizzle on a `float4`. | boundary | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`boundary-float4-swizzle-reverse.slang`](boundary-float4-swizzle-reverse.slang) |
| Boundary: `float4x4` is the maximum-square matrix vocabulary and `mul` is documented as an HLSL intrinsic; combining them at the largest square boundary scales the input vector component-wise via a diagonal matrix. | boundary | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`boundary-float4x4-mul-vector.slang`](boundary-float4x4-mul-vector.slang) |
| Boundary: `half` is the narrow floating-point type supplied by `core.meta.slang`; it is distinguishable from `float` by overload resolution. | boundary | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`boundary-half-overload.slang`](boundary-half-overload.slang) |
| Boundary: `int64_t` from `core.meta.slang` at its MAX value (9223372036854775807) binds the `int64_t` overload over a competing `int` overload. | boundary | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`boundary-int64-max.slang`](boundary-int64-max.slang) |
| Boundary: `int8_t` is one of the narrow integer types supplied by `core.meta.slang`; the value -128 is its documented MIN and selects the `int8_t` overload via overload resolution. | boundary | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`boundary-int8-min.slang`](boundary-int8-min.slang) |
| Boundary: `uint8_t` from `core.meta.slang` at its MAX value (255) binds the `uint8_t` overload and stores the documented max value. | boundary | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`boundary-uint8-max.slang`](boundary-uint8-max.slang) |
| Negative: `RWStructuredBuffer` is supplied by `hlsl.meta.slang` as a generic type and must be instantiated with a template argument; using the bare name rejects with `E30408`. | negative | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`negative-rwstructuredbuffer-missing-args.slang`](negative-rwstructuredbuffer-missing-args.slang) |
| Negative: `int` is a core-module type name; once a local named `int` exists, the parser still treats a subsequent leading `int` in a declaration as the type token, so `int x = int + 1;` is rejected because the parser cannot reuse the type name as a value expression. | negative | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`negative-int-as-identifier-in-expr.slang`](negative-int-as-identifier-in-expr.slang) |
| Stress: twelve `kind` overloads — one for each documented core-module scalar (`int8_t`, `int16_t`, `int`, `int64_t`, `uint8_t`, `uint16_t`, `uint`, `uint64_t`, `half`, `float`, `double`, `bool`) — all dispatch distinctly under overload resolution. | stress | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`stress-twelve-numeric-overloads.slang`](stress-twelve-numeric-overloads.slang) |
| `StructuredBuffer<T>` is an HLSL-flavored type supplied by `hlsl.meta.slang`; it survives into the emitted HLSL text. | functional | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`builtin-hlsl-structured-buffer.slang`](builtin-hlsl-structured-buffer.slang) |
| `int`, `uint`, `float`, and `bool` are core-module-supplied type names; overload resolution against typed parameters distinguishes all four. | functional | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`builtin-numeric-types-overload.slang`](builtin-numeric-types-overload.slang) |
| `vec3` is a GLSL-flavored name supplied by `glsl.meta.slang`; it is available when targeting GLSL emit. | functional | [#core-module-supplied-vocabulary](../../../design/syntax-reference/keywords-and-builtins.md#core-module-supplied-vocabulary) | [`builtin-glsl-vec3.slang`](builtin-glsl-vec3.slang) |
| A binding introduced by `let` is immutable; assignment to a let-bound name is a compile-time error. | negative | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`decl-let-immutable-rejected.slang`](decl-let-immutable-rejected.slang) |
| Boundary: `typedef` is the C-style decl keyword listed alongside `typealias`; the alias resolves to its underlying type for overload resolution just like `typealias`. | boundary | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`boundary-typedef-c-style.slang`](boundary-typedef-c-style.slang) |
| Boundary: `using` is listed in the decl-keywords table (`parseUsingDecl`); `using namespace N;` brings `N`'s members into the current scope so they may be looked up unqualified. | boundary | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`boundary-using-namespace.slang`](boundary-using-namespace.slang) |
| Boundary: an `enum` with `int`-typed underlying values accepts the documented int MIN (-2147483648) and int MAX (2147483647) as explicit case values. | boundary | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`boundary-enum-int-min-max.slang`](boundary-enum-int-min-max.slang) |
| Negative: a `let`-bound name is not an l-value, so it cannot be passed to an `inout` parameter even though the call site reads syntactically fine; the checker rejects with the l-value diagnostic. | negative | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`negative-let-through-inout-argument.slang`](negative-let-through-inout-argument.slang) |
| Stress: an eight-deep chain of `typealias` declarations must collapse end-to-end to `int` for overload resolution to select the `int` arm. | stress | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`stress-typealias-eight-deep-chain.slang`](stress-typealias-eight-deep-chain.slang) |
| Stress: five levels of nested `namespace` blocks resolved by a five-segment `::`-qualified lookup probe that the namespace decl-keyword does not collapse depth. | stress | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`stress-deeply-nested-namespace-scope.slang`](stress-deeply-nested-namespace-scope.slang) |
| `__init` is the decl keyword for a constructor; it is invoked when the type name is used as a call expression. | functional | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`decl-init-constructor.slang`](decl-init-constructor.slang) |
| `__subscript(args) -> T { get { ... } }` is a decl keyword that binds `v[args]` syntax to a user-defined accessor. | functional | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`decl-subscript-index.slang`](decl-subscript-index.slang) |
| `enum` is a decl keyword (dispatched via direct identifier lookahead, not the syntax table) introducing an enumeration with explicit case values. | functional | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`decl-enum-value.slang`](decl-enum-value.slang) |
| `extension <Type> { ... }` is a decl keyword that adds new members to an existing type without modifying its primary declaration. | functional | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`decl-extension-method.slang`](decl-extension-method.slang) |
| `func name(params) -> RetType { ... }` is the Slang-style function-decl form introduced by the `func` decl keyword. | functional | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`decl-func-arrow.slang`](decl-func-arrow.slang) |
| `interface` is the decl keyword that declares a protocol-style requirement set; a `struct` conforms via `:` and supplies the required member. | functional | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`decl-interface-conformance.slang`](decl-interface-conformance.slang) |
| `let` introduces an immutable binding and `var` introduces a mutable binding; both are decl keywords. | functional | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`decl-let-var.slang`](decl-let-var.slang) |
| `namespace name { ... }` is a decl keyword introducing a named scope whose members are reached with `::` qualification. | functional | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`decl-namespace-scope.slang`](decl-namespace-scope.slang) |
| `typealias Name = T;` is a decl keyword binding `Name` to type `T`; the alias resolves to its underlying type for overload resolution. | functional | [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | [`decl-typealias.slang`](decl-typealias.slang) |
| Boundary: `alignof` is documented in the same expression-keyword group as `sizeof`; `alignof(int)` returns 4, matching the size for a naturally aligned scalar. | boundary | [#expression-keywords](../../../design/syntax-reference/keywords-and-builtins.md#expression-keywords) | [`boundary-alignof-int.slang`](boundary-alignof-int.slang) |
| Boundary: `countof` is documented in the expression-keywords group with `sizeof`/`alignof`; for a variadic value pack of three elements, `countof(D)` is 3. | boundary | [#expression-keywords](../../../design/syntax-reference/keywords-and-builtins.md#expression-keywords) | [`boundary-countof-variadic-pack.slang`](boundary-countof-variadic-pack.slang) |
| Boundary: `nullptr` is documented in the expression-keywords table as the null pointer literal; it compares equal to itself when stored in a pointer-typed binding. | boundary | [#expression-keywords](../../../design/syntax-reference/keywords-and-builtins.md#expression-keywords) | [`boundary-nullptr-pointer-literal.slang`](boundary-nullptr-pointer-literal.slang) |
| Boundary: `sizeof(bool)` resolves to 1 byte; probes the lower end of the scalar-size domain. | boundary | [#expression-keywords](../../../design/syntax-reference/keywords-and-builtins.md#expression-keywords) | [`boundary-sizeof-bool-byte.slang`](boundary-sizeof-bool-byte.slang) |
| Boundary: `sizeof(double)` resolves to 8 bytes; pairs with the int boundary covered by `expr-sizeof-int.slang` to probe the upper end of the built-in scalar size range. | boundary | [#expression-keywords](../../../design/syntax-reference/keywords-and-builtins.md#expression-keywords) | [`boundary-sizeof-double.slang`](boundary-sizeof-double.slang) |
| Boundary: the `none` expression-keyword constructs an empty `Optional<T>` for `T = float` (the smallest floating-point payload), complementing the `Optional<int>` smoke test. | boundary | [#expression-keywords](../../../design/syntax-reference/keywords-and-builtins.md#expression-keywords) | [`boundary-optional-float-none.slang`](boundary-optional-float-none.slang) |
| `none` is the expression keyword for the empty value of `Optional<T>`; `hasValue` discriminates between the empty and present cases. | functional | [#expression-keywords](../../../design/syntax-reference/keywords-and-builtins.md#expression-keywords) | [`expr-none-optional.slang`](expr-none-optional.slang) |
| `sizeof` is an expression keyword that returns the size, in bytes, of its type operand at compile time. | functional | [#expression-keywords](../../../design/syntax-reference/keywords-and-builtins.md#expression-keywords) | [`expr-sizeof-int.slang`](expr-sizeof-int.slang) |
| `this` is an expression keyword denoting the current object inside a member function. | functional | [#expression-keywords](../../../design/syntax-reference/keywords-and-builtins.md#expression-keywords) | [`expr-this-self-reference.slang`](expr-this-self-reference.slang) |
| `true` and `false` are expression keywords producing boolean-typed values; they select different branches of a conditional. | functional | [#expression-keywords](../../../design/syntax-reference/keywords-and-builtins.md#expression-keywords) | [`expr-true-false-bool.slang`](expr-true-false-bool.slang) |
| `SV_`-prefixed identifiers are HLSL system-value semantics; `SV_Position` survives into HLSL emit as `SV_POSITION`. | functional | [#reserved-identifier-prefixes](../../../design/syntax-reference/keywords-and-builtins.md#reserved-identifier-prefixes) | [`reserved-sv-prefix-hlsl.slang`](reserved-sv-prefix-hlsl.slang) |
| `gl_`-prefixed identifiers stand for shader-stage built-ins supplied by `glsl.meta.slang`; the GLSL emit uses the gl_-prefixed spelling. | functional | [#reserved-identifier-prefixes](../../../design/syntax-reference/keywords-and-builtins.md#reserved-identifier-prefixes) | [`reserved-gl-prefix-glsl.slang`](reserved-gl-prefix-glsl.slang) |
| `dyn` is a simple modifier on an `interface` declaration that marks the interface for dynamic dispatch; declaring a `dyn interface` with a conforming struct parses and survives into a clean HLSL / SPIR-V emit. | expansion | [#simple-modifiers](../../../design/syntax-reference/keywords-and-builtins.md#simple-modifiers) | [`modifier-dyn-interface.slang`](modifier-dyn-interface.slang) |
| `groupshared` is a simple HLSL-flavored storage modifier; it lowers to `groupshared` in HLSL emit and to `shared` in GLSL emit. | functional | [#simple-modifiers](../../../design/syntax-reference/keywords-and-builtins.md#simple-modifiers) | [`modifier-groupshared-multitarget.slang`](modifier-groupshared-multitarget.slang) |
| `in`, `out`, and `inout` are simple parameter-direction modifiers; an `out`/`inout` parameter mutation is visible at the caller. | functional | [#simple-modifiers](../../../design/syntax-reference/keywords-and-builtins.md#simple-modifiers) | [`modifier-in-out-inout.slang`](modifier-in-out-inout.slang) |
| `public` and `private` are simple visibility modifiers; a `private` member is still reachable from another member of the same type. | functional | [#simple-modifiers](../../../design/syntax-reference/keywords-and-builtins.md#simple-modifiers) | [`modifier-public-private.slang`](modifier-public-private.slang) |
| `static` and `const` are simple modifiers; a `static const` file-scope binding is a compile-time-known value the parser accepts and the checker treats as read-only. | functional | [#simple-modifiers](../../../design/syntax-reference/keywords-and-builtins.md#simple-modifiers) | [`modifier-static-const.slang`](modifier-static-const.slang) |
| Boundary: `defer` is documented in the statement-keywords table (line 6406) but uncovered by the smoke tests; the body of the deferred statement runs after the enclosing function body completes. | boundary | [#statement-keywords](../../../design/syntax-reference/keywords-and-builtins.md#statement-keywords) | [`boundary-defer-statement-order.slang`](boundary-defer-statement-order.slang) |
| `break` exits the enclosing loop and `continue` skips to the next iteration; both are statement keywords. | functional | [#statement-keywords](../../../design/syntax-reference/keywords-and-builtins.md#statement-keywords) | [`statement-break-continue.slang`](statement-break-continue.slang) |
| `discard` is a fragment-shader statement keyword; it terminates fragment processing for the current invocation. | functional | [#statement-keywords](../../../design/syntax-reference/keywords-and-builtins.md#statement-keywords) | [`statement-discard-fragment.slang`](statement-discard-fragment.slang) |
| `for` is a statement keyword that opens a counted-loop header with init/condition/update clauses. | functional | [#statement-keywords](../../../design/syntax-reference/keywords-and-builtins.md#statement-keywords) | [`statement-for-loop.slang`](statement-for-loop.slang) |
| `if` and `else` are statement keywords recognized by direct identifier comparison in the statement parser; the conditional branches according to the boolean argument. | functional | [#statement-keywords](../../../design/syntax-reference/keywords-and-builtins.md#statement-keywords) | [`statement-if-else.slang`](statement-if-else.slang) |
| `return <expr>` is a statement keyword that hands a value back to the caller and ends the function. | functional | [#statement-keywords](../../../design/syntax-reference/keywords-and-builtins.md#statement-keywords) | [`statement-return.slang`](statement-return.slang) |
| `switch`, `case`, and `default` form the multi-way dispatch statement; the parser recognizes all three as statement keywords. | functional | [#statement-keywords](../../../design/syntax-reference/keywords-and-builtins.md#statement-keywords) | [`statement-switch-case.slang`](statement-switch-case.slang) |
| `while` and `do` are statement keywords parsing the head-tested and tail-tested loop forms respectively. | functional | [#statement-keywords](../../../design/syntax-reference/keywords-and-builtins.md#statement-keywords) | [`statement-while-do.slang`](statement-while-do.slang) |


## Untested claims
NA


## Doc gaps observed
| Anchor | Kind | Gap | Suggested addition |
| --- | --- | --- | --- |
| [#complex-modifiers-take-arguments](../../../design/syntax-reference/keywords-and-builtins.md#complex-modifiers-take-arguments) | undocumented-behavior | The `#complex-modifiers-take-arguments` table lists `layout`, `volatile`, `coherent`, `restrict`, etc. as taking arguments, but does not give a complete syntactic shape (what the argument list looks like, which contexts accept the modifier). No test in this bundle anchors there because the user-facing syntax is not described precisely enough to derive a verifiable claim. Filing as a doc gap would help. |  |
| [#expression-keywords](../../../design/syntax-reference/keywords-and-builtins.md#expression-keywords) | undocumented-behavior | `#expression-keywords` lists `try`, `no_diff`, `__fwd_diff`, `fwd_diff`, `__bwd_diff`, `bwd_diff`, `new`, and the shape/pack utility expressions (`__first`, `__last`, `__trimFirst`, ...) but does not document a minimum standalone use that would let us exercise them through `slangi`. Most need accompanying imports or generic-resolution machinery that would not fit in a single test file. Recorded as candidates for expansion once the doc spells out a self-contained example for each. |  |
| [#decl-keywords](../../../design/syntax-reference/keywords-and-builtins.md#decl-keywords) | undocumented-behavior | `#decl-keywords` says `struct`, `class`, and `enum` are not registered through `g_parseSyntaxEntries[]`. The text mentions `parseClassDecl` for `class` but no user-facing claim describes how `class` differs from `struct` for the user. | Without a documented behavioral difference, no test for `class` was added beyond the general decl-keyword family covered by `decl-enum-value.slang` and `decl-init-constructor.slang`. |
| [#rowmajor](../../../design/syntax-reference/keywords-and-builtins.md#rowmajor) | undocumented-behavior | `row_major` / `column_major` are listed as simple modifiers but their effect on HLSL emit is hidden by Slang's natural-layout rewriting, so the post-emit text does not contain the `row_major` token in a self-contained `cbuffer` test. | Without a documented user-observable claim distinct from the emit text, no test was added. |
| [#import](../../../design/syntax-reference/keywords-and-builtins.md#import) | undocumented-behavior | `import` is listed as a decl keyword but importing a real module (`diff`) from the agentic suite would require the matching `.slang` module to resolve in `slangi`'s search path. The no-GPU runner cannot reliably stage modules outside the test directory, so this claim was not exercised here. |  |
| [#countofarr](../../../design/syntax-reference/keywords-and-builtins.md#countofarr) | undocumented-behavior | `countof(arr)` on a plain fixed-size local array under `slangi` returned `4` (the size of `int` in bytes) rather than the array element count, regardless of the declared size. The variadic-pack form (`countof(D)` for `let each D : int`) returns the documented element count, so the `boundary-countof-variadic-pack.slang` probe uses the pack form. Worth a note in the doc that the array form is only constant-folded in some contexts, or that the canonical `countof` shape is the pack form. |  |
| [#let](../../../design/syntax-reference/keywords-and-builtins.md#let) | undocumented-behavior | The keyword-vs-identifier rules are not spelled out: `let`, `var`, and even `int` can be reused as identifier names in declarator position (e.g. `int let = 5;` is accepted), but `int` cannot appear at the head of an expression-typed declaration (`int x = int + 1;` is rejected with `E30060`). | A short paragraph on which contexts re-classify an identifier as a value vs a type would let us write more precise boundary tests. |
| [#reserved](../../../design/syntax-reference/keywords-and-builtins.md#reserved) | undocumented-behavior | `SV_`-prefixed and `gl_`-prefixed names are documented as "reserved", but in practice a user-named local `int SV_userVar` inside a function compiles and produces the printed value. The prefix policy is therefore advisory rather than enforced; a note to that effect in the doc would justify removing speculative user-prefix boundary tests. |  |
