fix: move top-level let initialization into main() in C backend
Top-level let bindings with function calls (e.g., `let result = factorial(10)`) were emitted as static initializers, which is invalid C since function calls aren't compile-time constants. Now globals are declared with zero-init and initialized inside main() before any run expressions execute. Also fixes validate.sh to use exit codes instead of grep for cargo check/build. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,7 +30,7 @@ fail() { printf "${RED}FAIL${NC} %s\n" "${1:-}"; FAILED=$((FAILED + 1)); }
|
||||
|
||||
# --- Rust checks ---
|
||||
step "cargo check"
|
||||
if nix develop --command cargo check 2>&1 | grep -q "Finished"; then ok; else fail; fi
|
||||
if nix develop --command cargo check 2>/dev/null; then ok; else fail; fi
|
||||
|
||||
step "cargo test"
|
||||
OUTPUT=$(nix develop --command cargo test 2>&1 || true)
|
||||
@@ -39,7 +39,7 @@ if echo "$RESULT" | grep -q "0 failed"; then ok "$RESULT"; else fail "$RESULT";
|
||||
|
||||
# --- Build release binary ---
|
||||
step "cargo build --release"
|
||||
if nix develop --command cargo build --release 2>&1 | grep -q "Finished"; then ok; else fail; fi
|
||||
if nix develop --command cargo build --release 2>/dev/null; then ok; else fail; fi
|
||||
|
||||
# --- Package tests ---
|
||||
for pkg in path frontmatter xml rss markdown; do
|
||||
|
||||
Reference in New Issue
Block a user