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.
29 lines
1.4 KiB
Plaintext
29 lines
1.4 KiB
Plaintext
// The 7 type-introspection builtins (size_of, align_of, field_count,
|
|
// type_name, type_eq, type_is_unsigned, is_flags) take ONLY types. A
|
|
// value argument is a compile-time error, not a silently-reinterpreted
|
|
// TypeId index.
|
|
//
|
|
// Regression (issue 0090, attempt 2): each builtin used to accept a
|
|
// non-type value and reinterpret it — `type_is_unsigned(6)` read 6 as a
|
|
// TypeId and returned the signedness of types[6] (`u8` → true);
|
|
// `size_of(true)` sized `typeof(true)` (8). The strict `$T: Type` guard
|
|
// (`Lowering.reflectionTypeArgGuard`) now rejects any argument whose
|
|
// static type is not `Type` and emits "<builtin> expects a type, got
|
|
// '<type>'" at the offending argument, aborting (exit 1).
|
|
//
|
|
// Reject cases use `true`/`1.5` (whose types — bool/f64 — are stable)
|
|
// rather than an integer literal, so the pinned diagnostics don't drift
|
|
// when the int-literal default type changes.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
main :: () {
|
|
print("{}\n", size_of(true)); // bool, not a type
|
|
print("{}\n", align_of(1.5)); // f64, not a type
|
|
print("{}\n", field_count(true)); // bool, not a type
|
|
print("{}\n", type_name(1.5)); // f64, not a type
|
|
print("{}\n", type_eq(true, false)); // both bool — both rejected
|
|
print("{}\n", type_is_unsigned(true)); // bool, not a type
|
|
print("{}\n", is_flags(1.5)); // f64, not a type
|
|
}
|