// LANGUAGE PREVIEW — compiles and runs in this browser playground.
// Runs on the pinned Rust/Wasm compiler; Java/LLVM parity is not claimed.
// Conditional returns — exact browser guest oracle in example-backend-profile.json.
// Language target: atto-spec #330; Rust/Wasm implementation: #850.
// Success-gated return is NOT postfix failure propagation.
// Default: nonzero int, true, Some(payload), Ok(payload).
// Explicit = selectors replace the default rule. Evaluate the operand once.

fnc first_nonzero(int a, int b): int {
  ^? a;
  return? b;
  return -1;
}

fnc approved(int candidate): int {
  ^?=0 candidate;             // explicit zero is approved
  return?=[1, 42] candidate;  // exact typed equality
  return -1;
}

fnc first_present(Option<int> a, Option<int> b): int {
  return? a;
  ^? b;
  return -1;
}

fnc first_ok(Result<int, string> a, Result<int, string> b): int {
  ^? a;
  return? b;
  return -1;
}

fnc first_true(bool value): bool {
  ^? value;
  return false;
}

pub fnc main(): int {
  stdio.println(first_nonzero(0, 42));       // 42
  stdio.println(approved(0));                // 0
  stdio.println(approved(42));               // 42
  stdio.println(approved(7));                // -1
  stdio.println(first_present(None, Some(0))); // 0, not -1
  stdio.println(first_ok(Err("no"), Ok(0)));   // 0, not -1
  stdio.println(first_true(true));           // true
  return 42;
}

// INVALID: ^?=[] 42;             empty selector
// INVALID: return?=[true] 42;    selector type mismatch
// INVALID: ^ ? 42;               split marker
// INVALID: ^? 0; as only return in an int function (missing fallback).
