---
generated: true
model: claude-sonnet-4-6
generated_at: 2026-06-02T09:36:11+00:00
source_commit: 273e29cb6cac600f70da7245a506bae6689e0e23
watched_paths_digest: fa1615f04e0c9b2aa98e22763da6498a6b8aff8e565ef7614923ece1ac3fa420
source_doc: docs/language-reference/expressions-initializer.md
source_doc_digest: e467ce72665cfeb88303b216e92eb9c0a2cf31f38be2f0d4c2710193bef034c5
warning: "Auto-generated. May drift from source. Do not edit by hand."
---

# Tests for conformance/expressions-initializer

## Intent

Tests verify the initializer-expression and initializer-list-expression
claims in the **language reference** at
[`docs/language-reference/expressions-initializer.md`](../../../../language-reference/expressions-initializer.md).

The doc is marked `> TODO` at the top, but below that marker it makes
concrete normative statements about two distinct language features:
(1) initializer expressions (type-as-callee calls) and (2) initializer
list expressions (`{ … }`). Coverage strategy: one functional test per
claim, plus boundary cases for zero-element lists and a functional+emission
pair for the single-arg-as-cast claim (C3). The doc's stated restriction
on where init lists may appear (C5) is partially at odds with the
compiler's actual behaviour and is recorded as a doc gap rather than
exercised as a negative test.

## Claims

### Initializer Expressions

- **C1** — When the base expression of a call is a type instead of a value, the expression is an initializer expression that creates an instance of the named type. (The doc's example: `float2(1.0f, 2.0f)`.)
- **C2** — An initializer expression initializes an instance of the specified type using the given arguments (argument values flow into the instance's fields/components).
- **C3** — An initializer expression with only a single argument is treated as a cast expression; `int(1.0f)` and `(int) 1.0f` are equivalent.

### Initializer List Expression

- **C4** — An initializer list expression comprises zero or more expressions, separated by commas, enclosed in `{}`.
- **C5** — An initializer list expression may only be used directly as the initial-value expression of a variable or parameter declaration; initializer lists are not allowed as arbitrary sub-expressions.

## Functional coverage

| Claim                                                                                                                                                                                        | Intent     | Anchor                                                                                                                | Tests                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| C1: A type-as-callee call (e.g. `float2(x, y)`) is an initializer expression that produces a value of the named type.                                                                        | functional | [#initializer-expressions](../../../../language-reference/expressions-initializer.md#initializer-expressions)         | [`initializer-expr-multi-arg-functional.slang`](initializer-expr-multi-arg-functional.slang)                                                                                                                   |
| C2: An initializer expression initializes an instance of the specified type using the given arguments — verified on a user struct `Point(x, y)`.                                             | functional | [#initializer-expressions](../../../../language-reference/expressions-initializer.md#initializer-expressions)         | [`initializer-expr-multi-arg-struct-functional.slang`](initializer-expr-multi-arg-struct-functional.slang)                                                                                                     |
| C3: A single-argument initializer expression `int(f)` produces the same value as the C-style cast `(int)f`.                                                                                  | functional | [#initializer-expressions](../../../../language-reference/expressions-initializer.md#initializer-expressions)         | [`initializer-expr-single-arg-cast-functional.slang`](initializer-expr-single-arg-cast-functional.slang), [`initializer-expr-single-arg-cast-emission.slang`](initializer-expr-single-arg-cast-emission.slang) |
| C4 (basic): An initializer list `{ r, g, b }` used as a variable declaration initial-value initializes each field in declaration order.                                                      | functional | [#initializer-list-expression](../../../../language-reference/expressions-initializer.md#initializer-list-expression) | [`initializer-list-var-decl-functional.slang`](initializer-list-var-decl-functional.slang)                                                                                                                     |
| C4 (boundary): A zero-element initializer list `{}` is valid ("zero or more expressions").                                                                                                   | boundary   | [#initializer-list-expression](../../../../language-reference/expressions-initializer.md#initializer-list-expression) | [`initializer-list-zero-element-functional.slang`](initializer-list-zero-element-functional.slang)                                                                                                             |
| C4 (array): An initializer list used as the initial-value of a fixed-size array variable initializes each element in index order.                                                            | functional | [#initializer-list-expression](../../../../language-reference/expressions-initializer.md#initializer-list-expression) | [`initializer-list-array-functional.slang`](initializer-list-array-functional.slang)                                                                                                                           |
| C4 (combination/nested): Nested initializer lists `{ {a,b}, {c,d} }` initialize nested struct fields in declaration order.                                                                   | functional | [#initializer-list-expression](../../../../language-reference/expressions-initializer.md#initializer-list-expression) | [`initializer-list-nested-functional.slang`](initializer-list-nested-functional.slang)                                                                                                                         |
| C5 (positive path): An initializer list used as the initial-value of a parameter declaration (default argument) initializes the parameter when the function is called without that argument. | functional | [#initializer-list-expression](../../../../language-reference/expressions-initializer.md#initializer-list-expression) | [`initializer-list-param-decl-functional.slang`](initializer-list-param-decl-functional.slang)                                                                                                                 |

## Untested claims

| Claim                                                                                                                                                         | Reason        | Anchor                                                                                                                | Why untested                                                                                                                                                                                                                                                                                                                                                                                          |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| C5 (negative path): An initializer list is not allowed as an arbitrary sub-expression (e.g. as a function argument, in a return statement, or in assignment). | out-of-bundle | [#initializer-list-expression](../../../../language-reference/expressions-initializer.md#initializer-list-expression) | The compiler accepts init lists in all of these contexts (function-call arguments `foo({1,2})`, return expressions `return {5,6}`, and assignment `p = {3,4}`). The doc's restriction does not match observed compiler behaviour; this is recorded as a doc gap below. A negative test anchored to this doc claim would fail against the compiler — the discrepancy is a doc gap, not a compiler bug. |

## Doc gaps observed

| Anchor                                                                                                                | Kind              | Gap                                                                                                                                                                                                                                                                                                                                        | Suggested addition                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| --------------------------------------------------------------------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |   |
| [#initializer-list-expression](../../../../language-reference/expressions-initializer.md#initializer-list-expression) | drift-from-source | The doc states "initializer lists are not allowed as arbitrary sub-expressions", but the compiler accepts them in at least three additional contexts: function-call arguments (`foo({1,2})`), return expressions (`return {1,2}`), and assignment (`p = {3,4}`). These are reachable user-level surfaces that the doc claims are rejected. | Revise the restriction sentence to accurately describe where init lists are accepted. Based on observed compiler behaviour, the accurate statement is something like: "An initializer list may appear in any context that expects a value of a type that can be initialized from an ordered list of sub-expressions (variable and parameter declarations, return statements, function arguments, and assignment)." If the broader acceptance is intentional, the doc should say so; if the restriction is intended, the compiler needs a diagnostic. |
| [#initializer-list-expression](../../../../language-reference/expressions-initializer.md#initializer-list-expression) | missing-surface   | The doc's `> Note` acknowledges that "detailed rules for how expressions in the initializer list are used to initialize values of each kind of type" are not yet documented. This leaves the field-ordering, partial-initialization, and type-coercion rules as unspecified.                                                               | Expand the section with the field-assignment and array-element ordering rules, whether partial initialization is allowed, and how type coercions in the list are performed.                                                                                                                                                                                                                                                                                                                                                                          |
