Files
sx/examples/types/0156-types-backtick-struct-const.sx
agra 66bdc70bf1 test: group examples into per-category folders
Move examples/*.sx and their expected/ snapshots into per-category
subfolders (examples/<category>/...). Folder = leading filename token,
with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus
runner and LSP sweep now discover each category's expected/ dir, while
issues/ stays flat. Example 1058's repo-root-relative companion import
is made file-relative. Path strings embedded in 164 snapshots were
regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
2026-06-21 14:41:34 +03:00

22 lines
967 B
Plaintext

// Backtick raw-identifier escape at a STRUCT-BODY constant — both the untyped
// `` `name :: value `` and the typed `` `name : T : value `` forms. A struct
// member constant is a binding site like any top-level const (examples/0153),
// so a reserved type spelling (`i2`, `u8`) needs the backtick to be used as the
// constant's name; the value is read back via `Holder.`name`. A *bare*
// reserved-name struct const still errors with the caret on the name (see
// examples/1142). The backtick is never part of the name's text.
// Regression (issue 0089 — attempt-5: struct-body const decls thread is_raw +
// the precise name_span, previously dropped to a false reject / 1:1 caret).
#import "modules/std.sx";
Holder :: struct {
`i2 :: 5; // untyped raw struct-body const
`u8 : i64 : 9; // typed raw struct-body const
}
main :: () -> i32 {
print("untyped = {}\n", Holder.`i2);
print("typed = {}\n", Holder.`u8);
return 0;
}