xpile 0.1.616

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
# PMAT-1168: a no-default d.get(k) in an f-string field is Option<T>. Python
# f"{d.get(k)}" == str(d.get(k)), which renders "None" for the absent key and the
# value otherwise. This now transpiles to `if opt.is_none() { "None" } else {
# str(inner) }` — parity with the str() builtin (PMAT-857). Supersedes PMAT-620's
# blanket reject (which was stale once str(d.get(k)) started rendering). An
# Optional *variable* is covered by the same path.
def f(d: dict[str, int], k: str) -> str:
    return f"val={d.get(k)}"


def opt_var() -> str:
    x = None
    return f"x={x}"