Files
sx/examples/modules/0705-modules-inline-if-hoist-toplevel.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

25 lines
890 B
Plaintext

// Regression: top-level `inline if OS == .X { ... }` body decls get
// hoisted to the actual top level. Before this commit, the `if_expr`
// landed in `root.decls` but `scanDecls` had no `.if_expr` arm, so the
// body was silently dropped — chess's
// `inline if OS == .android { SxApp :: #jni_main #jni_class(...) { ... } }`
// was invisible to the compiler. Fix:
// `imports.flattenComptimeConditionals` runs at the head of
// `resolveImports` and replaces matching arms with their body stmts
// (recursively, so a nested `inline if` inside a hoisted arm also
// hoists).
//
// Three patterns covered: a global `var_decl`, an `#import`, and a
// nested `inline if` whose else arm fires on host macOS.
#import "modules/std.sx";
inline if OS == .android {
#import "modules/std.sx";
g_value : i64 = 99;
} else {
g_value : i64 = 42;
}
main :: () { print("{}\n", g_value); }