Skip to content

0.7.2

Latest

Choose a tag to compare

@franknoh franknoh released this 27 Oct 17:06
ee38843

Changes

The C that ppy emit c and ppy emit cpp write reads like hand-written C in every form, library included, and ppy build --library gives C callers a library they can link and errors they can handle.

Structured C

  • Every function is written with while, if/else, break, continue, and return. Loops with several exits, shared raise and clean-up paths, generator resumes, and regex matchers no longer fall back to labels and goto; a failed check returns where it happens instead of jumping to fallback:.
  • Tests that share a target are written as one condition (if (!seen || x > best)), and an if that returns has no else.
  • No function in examples/ falls back to labels in any form (library, --standalone, --unsafe, and C++). On 0.7.1, 27 of the 183 emitted files did.

Libraries

  • ppy build --library stops with E1807 when an exported function did not lower, naming the function and the reason, instead of leaving it out of the header.
  • The library links libm, so a C consumer needs only pkg-config --libs <name>.
  • An export whose Python code raises returns 0, and ppy_last_error() gives CPython's last line for the exception (IndexError: list index out of range), instead of killing the caller with SIGILL. ppy emit c exports print that line before they abort.

Fixed

  • The safe C form no longer writes string constants that no function reads, which -Wunused-variable flagged on Python 3.12 and 3.13.

Install or upgrade with pip install --upgrade "ppy-lang[llvm]==0.7.2".

The full repository gate passed on Python 3.12, 3.13, and 3.14, with the emitted C of the new tests run under AddressSanitizer and UndefinedBehaviorSanitizer.