xpile 0.1.615

Polyglot transpile workbench (Python/C/C++/Rust/Ruchy/Lean ↔ Rust/Ruchy/PTX/WGSL/SPIR-V) with provable contracts at every layer.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# PMAT-858 (HUNT-V29 #3): `expr or default` / `expr and y` returning the operand
# by truthiness previously required every LEADING operand to be a bare name (safe
# to evaluate twice). That rejected the very common `d.get(k, 0) or default` /
# `s.strip() or default` (a method/call lead). A non-name lead is now bound to a
# typed temp ONCE (single eval + short-circuit, matching Python). vs python3.


def via_call(d: dict[str, int]) -> int:
    return d.get("k", 0) or 99


def via_method(s: str) -> str:
    return s.strip() or "empty"


def via_name(x: int, y: int) -> int:
    return x or y