Skip to content

TyPy 0.1.0

Choose a tag to compare

@github-actions github-actions released this 07 Nov 16:29
· 7 commits to main since this release
86e9500

The first release. TyPy 0.1 compiles programs made of module-level
functions and statements over int, float, str, bool and None to
native executables for x86_64 Linux, with glibc or statically with musl.
Each program it accepts prints what CPython 3.12 to 3.15 prints. The
compiler needs glibc 2.39 or later and a C toolchain.

Added

  • Engineering documents: research, requirements specification, use case
    and domain models, architecture, decision records ADR-0001 to ADR-0008,
    detailed design for 0.1, test plan and development guide.
  • A development container with Rust 1.99.1, LLVM 23, musl, CPython 3.12 to
    3.15 for conformance testing, and the documentation tools.
  • The typy-diagnostics crate: source spans, diagnostic codes, the code
    registry and text rendering, with unit and property tests.
  • The typy-source crate: reading source files with the 16 MiB and UTF-8
    checks, line and column positions, parsing with the program's Python
    floor, and TyPy's own syntax tree with its text dump.
  • The typy-check crate: the 0.1 feature table, name resolution with
    Python's scoping, type inference within a function, definite assignment,
    and the typing rules for the operators and builtins of 0.1. Every
    rejection names its rule.
  • The typy-tyir crate: TyIR's types, a function builder, a verifier that
    checks definitions by dominance and the types of every operation, and the
    text form for --emit=tyir.
  • The typy-lower crate: lowers a checked program to TyIR with reference
    counting, error returns through invoke, and the semantics of CPython for
    loops, and, or, comparison chains and the builtins of 0.1.
  • The typy-codegen crate: turns TyIR into LLVM 23 IR, assembly and object
    code, with static immortal constants and traceback entries on raising
    calls; --release-small marks functions minsize, as LLVM 23 has no Oz.
  • The typy-runtime crate, without the standard library: object headers,
    reference counting, str objects and their operations, exceptions with
    tracebacks and the uncaught-exception report, buffered output, the stack
    check and main. make runtime builds the archive programs link.
  • Unlimited-size int in the runtime: arithmetic, //, % and ** with
    Python's floor rules, bitwise operators and shifts, comparisons, and
    conversion to and from str with int()'s parsing rules and CPython's
    4300-digit limit. Error messages match CPython's.
  • float in the runtime: /, //, %, ** and abs with CPython's
    special cases; int / int, float(int) and float(str) rounded once to
    the nearest double; exact int(float) and exact comparison of int with
    float; and repr with CPython's shortest digits and layout.
  • Every division by zero raises ZeroDivisionError: division by zero, the
    wording of CPython 3.14 and later (OI-14).
  • repr of a string escapes exactly the code points CPython 3.15 escapes,
    from Unicode 17.0 tables generated from CPython's own data (OI-15).
  • chr and ord in the runtime, with CPython's messages.
  • int() and float() read decimal digits of every script, such as
    int("\u0661\u0662"), which is 12.
  • The typy-build crate: build requests, modes and --emit stages, and
    the link of an object file with the runtime archive through cc or
    musl-gcc. The executable appears whole or not at all; a missing
    toolchain program is E0701, a failed link E0702, and a missing runtime
    archive, or one from another TyPy version, E0703.
  • Diagnostics without a source location, such as a failed link.
  • The typy command: typy check FILE, typy build FILE with --emit,
    -o, --release and --release-small, and typy run FILE -- ARGS,
    which keeps each build in a cache under TYPY_HOME and runs it again
    without compiling. Exit status 0 on success, 1 for program errors, 2 for
    wrong usage and 101 for an internal error, which a panic also becomes.
  • The typy-conformance crate and a conformance suite of 89 programs in
    tests/conformance/: each accepted program runs under CPython 3.12 to
    3.15 and under TyPy in debug and release mode, with the same output,
    exit status and last line of standard error; each rejected program gets
    exactly its diagnostic code at its line and column. make test runs it.
  • Every accepted conformance program also runs linked with AddressSanitizer
    and LeakSanitizer and must show no report. A program that ends with an
    uncaught exception frees the exception before it exits, so it leaks
    nothing.
  • The sanitizer run uses a runtime built with AddressSanitizer, so every
    memory access the runtime makes is checked. make miri runs the
    runtime's unit tests under Miri, and make fuzz fuzzes the source,
    checking and lowering stages.
  • Continuous integration: the quality gate and the release archive on
    every pull request, Miri and 30 minutes of fuzzing on demand before a
    release, code scanning, dependency review, and monthly grouped Dependabot
    updates. A tag vX.Y.Z releases the
    version after a maintainer approves it.
  • make dist builds a reproducible release archive of the compiler and its
    runtime archives, and runs a program with it unpacked.
  • make check measures branch coverage as well as line coverage and fails
    below 95 percent of either (NFR-11); make coverage-branches runs that
    measurement alone, and make test-int, make test-e2e and
    make test-all run one test level each.
  • Golden tests of every text stage of --emit and of rendered
    diagnostics in tests/golden/; make bless rewrites them.
  • End-to-end tests for a missing or failing C toolchain, an empty program,
    the 16 MiB limit, a file that is not UTF-8, two builds at once, argument
    forwarding by typy run, and environment variables that must not change
    the output.
  • The stack check reads the stack pointer register, so RecursionError
    is raised in time also when locals do not live on the machine stack.
  • The runtime archive is built for musl as well as glibc, and make check
    checks its size: 40.3 KB, and 29.8 KB without large integers (NFR-02). A
    hello world built with --release-small and linked statically with musl
    is 75 KB (NFR-01).
  • E0106 when an output file cannot be written; the linker reports a
    directory it cannot write with E0106 instead of E0702.
  • The typy-driver crate: runs loading, checking, lowering, code
    generation and linking in order, and stops after the stage --emit
    names. --emit=typed-ast writes every node with its position and type,
    and --emit=tyir leaves out the inc and dec that --emit=tyir-mem
    shows.
  • A quality gate, make check, that checks formatting, runs Clippy and the
    tests with at least 95 percent line coverage, lints the documents, checks for
    non-ASCII text, checks that every requirement has a row in the test plan,
    and checks that every diagram is rendered from its source.