Maylang 0.15.1 — Fern

Released 2026-11-14 UTC. A patch release that prepares the repository for public access and removes Any from the library and the tools. The legacy maypkg package manager is gone; projects use may workspaces. Strict typing narrows Optional<T> after a nil check and lets a closure inside a generic function name its type parameters, and the language gains hexadecimal, octal and binary integer literals with digit separators. Generated code gets faster again: a top-level main and Float loop bodies compile to native words, records are built into fixed slots, enum payload reads and map probes skip runtime calls, and a bounded collection threshold cuts the collector's pause and peak footprint. Doc comments are now the single source of the API reference, and the repository gains an MIT license and a security policy.

Repository

  • Prepared the repository for public access. The unmaintained frozen/ tree (other targets, NodeOS, the core runtime, maybrowser, mayos, stdlib/ml and archived examples) was removed from main; its last version is the frozen-archive tag. Also removed: the dated repository audit, docs/history/, the stale compliance snapshots, a duplicate .github/CONTRIBUTE.md and a scratch example. mayc now says target … is not supported instead of is frozen, and the language server no longer skips directories named frozen.

  • Removed the legacy maypkg package manager and every mayproj.json. Projects use may workspaces; may migrate still converts an older mayproj.json. The example projects that used maypkg (starfall, kaindsim, rivet, sdl_test and the learning projects) now have may.json manifests, and kaindsim's and rivet's Makefiles compile with mayc directly. Release bundles and installers no longer ship maypkg; saved component lists and --components values that name it are ignored, so older installations still upgrade.

  • Added a security policy with private vulnerability reporting, an experimental-status note in the README, and a roadmap rebuilt from the open issues.

Language

  • Strict typing narrows Optional<T> to T after a nil check: inside if (x != nil), in the else-branch of if (x == nil), on the right of x != nil and ..., and for the rest of a block after an if (x == nil) { return ...; } guard. Only names their module never assigns narrow (strict guide).

  • Strict typing for generics: a closure inside a generic function can name the enclosing function's type parameters (compose<A, B, C> can return fun(x: A) -> C), and a type parameter no argument determines becomes Never at the call, so let xs: List<Int> = stack(); is accepted. reverse of a Str is typed Str, as the runtime returns, instead of List<Str> (strict guide).

  • The standard library uses concrete and generic types instead of Any: algo, iter, functional, collections, stats, random, csv, format, string, path, math, test, io, net, validate and the prelude. Any remains only at dynamic boundaries, each commented: JSON, validators that inspect runtime types, mixed-type [a, b] pairs, and the Int-or-Float helpers square, cube, average and median. Breaking: callers holding Any values must use the real types; stacks are List<T>, queues List<List<T>> and sets Map<T, Bool>; stats_* results that can be undefined are Optional<Float> and stats_linear_regression returns a Regression struct; random_new returns a Random struct; validate_all takes ValidationRules and returns a Validation (contracts).

  • The examples use concrete types: Any dropped from 348 to 26 uses, all commented dynamic boundaries (JSON documents, the ledger's untrusted input stream, extern_c callables). market, game, ledger, features, maytasks, starfall and kaindsim model their data with structs; their output and exported files are unchanged. maytasks now skips malformed saved tasks instead of listing them as nil, and starfall starts a fresh flight from a truncated save file instead of failing with a type fault. unique is typed as returning its list element type.

  • may and the shared tool modules use concrete types: may.json is validated as JSON as before, then decoded into TargetSpec, Profile, Dependency and Config structs, and builds return Artifacts. Because a target's cache identity includes its serialized spec, existing .may/ caches rebuild once. tools/shared/imports.may keeps only the import scanner may uses; its graph traversal and brace checker were dead code after the maypkg removal. An empty [] or {} now joins with a typed collection (xs ?? []).

  • maylsp uses concrete types: indexed documents are Doc structs holding Token, Scope, Def and Import values, ranges and positions are Range/Position, and queued navigation and workspace requests and diagnostic waiters are structs instead of string-keyed maps. Lookups return Optional<Def>/Optional<Doc> and rely on nil narrowing. Any remains at the JSON-RPC boundary — parsed messages, replies and the diagnostic caches, which a forked worker serializes and the parent stores as a parsed snapshot. Behavior and protocol output are unchanged.

  • Hexadecimal 0xff, octal 0o755 and binary 0b1010 integer literals, and _ digit separators in every numeric literal (1_000_000, 0xffff_ffff, 6.022_140e2_3). Prefixes are lowercase; each _ must sit between two digits; every radix has the signed 64-bit range, with the minimum reached through unary minus. Invalid digits, misplaced separators, uppercase prefixes and radix fractions are lexer errors. 1_000 was documented before but did not compile. The formatter keeps a hexadecimal E from reading as an exponent, the VS Code grammar highlights the new forms, and the Rust bootstrap lexer accepts them too. String conversions (int, float) still read decimal only.

  • Behavior contracts admit the numeric conversions and rounding primitives: to_float, float, int, trunc, floor, ceil, round, sqrt and abs have empty effect rows when the checker can establish that their single argument is an Int or Float. Other arguments, including Bool, fail closed. int, trunc and abs can still raise catchable arithmetic faults, as / can (docs).

  • Behavior contracts admit the scalar mathematics: sin, cos, tan, ln, log2, log10, exp, pow and ** with a Float operand on Int or Float arguments, min/max on two arguments of the same type, and bool on Int, Float or Bool. Int ** Int and mixed min/max stay unknown (docs). Strict typing now types pow as returning Float instead of Any.

Tooling

  • mayc has a command surface instead of flags only: mayc run <source> [-- ARGS...] compiles to a private temporary executable in $TMPDIR/mayc-run-<pid>/, forwards the arguments after -- unchanged and exits with the program's status (removing the temporary directory unless -o names a path); mayc check <source> and mayc build <source> are subcommand forms of --check and the default. Diagnostics keep their source excerpt and caret span but now carry a stable error[E_STAGE] code and honor --color auto|always|never / --no-color (auto uses a terminal's stderr unless NO_COLOR is set). -O0/-O1/-O2 select the optional backend passes and the inliner, and --deps FILE writes a Make-style dependency file naming the produced binary, every expanded import, the compiler and the runtime sidecars that were read. --help documents the commands and options (compiler guide, toolchain reference).

  • may gained a scriptable command surface: may list [--json] describes targets, defaults and prerequisites, may which [TARGET] [--build] [--json] prints the artifact path a target would use without compiling (exit 1 until it exists), may test --list and may test --filter PATTERN narrow the discovered .test.may files, and may version/may doctor report toolchain identity and dependency-lock state as text or JSON. Global -C DIR, -q and -v work before or after the command (everything after -- still belongs to the program), and verbose builds print the exact compiler/recipe command and per-target time (workspace runner).

Performance

  • Language-server call hierarchy and navigation replies (measurements): callHierarchy/incomingCalls now streams through the navigation worker's 32-file batches like references, instead of loading the whole workspace into the worker, and the parent forwards worker results without parsing and re-encoding them. On 3,000 files with 4 callers each, incoming calls drop from 11.71 s and 560 MiB peak to 2.47 s and 188 MiB, and references from 3.06 s to 1.93 s. benchmark_call_hierarchy.py reproduces the measurements, and a new test checks incoming calls across batch boundaries.

  • Native Float loop bodies and a native Float main (reports: loops, main, follow-up): a Float function that contains a loop now compiles as native-word code. Declared Float locals get pre-planned XMM8-15 homes that survive iterations and are spilled/reloaded around calls, operations coalesce into their dead left operand, >/>= fuse into ucomisd plus one branch, and a call-free body keeps the raw backend's Int local registers and fusions; an escaped Float function is demoted to the tagged ABI so dynamic calls keep the tagged fault rules. The Float loop microbenchmark drops 82.6% and the cross-language Mandelbrot is unchanged as a control. A top-level body whose values are all Int/Bool/Float words now also compiles as a native-word main, which makes the cross-language top-level Mandelbrot native: 45.0 to 42.1 ms (1.4x to 1.2x the C build), with the tagged main kept as the fallback and Float boxed as fat type 3 only at print. Multi-argument print arguments are reified into frame slots first, because its boxing helpers are several runtime calls behind one IR call site (that clobber was found and fixed before merging). --no-opt still keeps all of it tagged, and native_float_loops.may, main_native_floats.may, the oracle suite and backends.py objdump assertions cover the boundaries. Still tagged: int(Float), the sqrt/rounding/min-max family, extern Float signatures and Float globals (status).

  • Collector pause and the default threshold policy (report): the post-sweep threshold is bounded at the allocation frontier instead of the frontier plus the margin, removing the frontier creep that raised the heap by 8 MiB per collection; the mark drain traces sealed-record payloads exactly (the key slots are image strings) and the 1 MiB global-root address table is a byte-kind block the collector never scans, which removes 95% of the conservative mark probes. On binary trees depth 16: CPU 0.9138 to 0.8345 s (-8.7%), peak RSS 236 to 146 MiB (-38%), collections 11 to 16, total pause 352 to 248 ms; the other seven roadmap workloads do not collect at the default floor and are unchanged within the layout spread (worst case sieve +1.2% over 30 pairs, +0.6% over 100), and the compiler self-compile is 5.0% faster at the same peak RSS. The measured negatives (skipping record zeroing, a sweep table-clear restructure) are in the report.

  • Allocating-safepoint inventory for precise stack maps (report): mayc --stack-map-inventory <src> prints the call sites that can start a collection while the caller's frames are live, as one JSON object, and exits; the normal path never runs the analysis and compiler images are byte-identical with and without it. The inventory computes the "can reach rt_alloc_kind" fixpoint over fat and raw call graphs, treats indirect calls and unresolved runtime names as allocating, and splits sites by call kind and frame shape. The compiler image has 8,086 fat-frame safepoints, which at the design's 2-bit-per-slot bound is about 40 KiB (1.35% of the code) rather than the 1.14 MiB (38%) an all-call-site scan implied, so map size is not the binding constraint; descriptor encoding, liveness precision and the collector switch remain open. tests/stack_maps.py pins the JSON contract.

  • Opt-in inliner (report): --inline (default off) clones only small, straight-line, effect-free accessor and one-expression-helper bodies into their call sites, declining anything else. An accessor measures -39.2% and a one-expression helper -73.0% in the inlining microbenchmarks (25/25 rounds each); the default build and every suite program are byte-identical, and the oracle suite now also compiles every behaviour fixture with --inline and requires identical output. The flag is skipped under --no-opt, --raw and --debug.

  • Phase 4 measurements (escape analysis, code alignment): a caller-side escape analysis of constructor calls reports zero non-escaping sites on every roadmap benchmark and on the compiler, because a constructor is a generated function that returns the record; the scalar replacement it enables is -98.4% on a hand-written microbenchmark but flat on n-body, trees and self-compile with byte-identical images, so the rewrite was reverted and the analysis kept as the decision set. Porting the raw backend's 16-byte body and loop-head alignment to fat code was measured negative in both a combined and a loop-only variant (consistent small regressions on sieve/hashmap/ strings, no consistent win) and reverted; the report keeps the numbers and the --no-code-align scope proof. Neither changes the default compiler.

  • Inline map probing for Float and Bool keys (report): the probe's key types now match the runtime's: Float keys hash with rt_hash_mix and the -0.0 fold and compare with rt_same's IEEE equality (-0.0 equals +0.0, NaN equals nothing), and Bool keys use the folded payload hash and payload equality. The fallback set is unchanged (non-map receivers, dynamic values, sub-threshold maps, growth, faults, --no-opt). A Float+Bool-key map workload drops from 258.8 to 126.1 ms (-51.3%); the Str-key probe and hashmap controls compile to byte-identical binaries and do not move, so existing workloads are unchanged. tests/map_probe_keys.may and the oracle test cover the semantics.

  • GC floor and margin overrides (report): MAYC_GC_MIN and MAYC_GC_MARGIN (decimal bytes) replace the collection floor and margin derived from the nominal heap, so the threshold policy can be tuned per run without rebuilding the runtime. Defaults are unchanged when the variables are unset or invalid, and the accepted range keeps a typo from disabling collection. Under MAYC_GC_MIN=8388608 MAYC_GC_MARGIN=524288 binary trees drops from 234 MiB to 95 MiB peak RSS at 1.75x the run time and 60 instead of 11 collections, hashmap drops 30% and strings 37% while six of the eight roadmap workloads do not collect at the default heap and are unchanged. The overrides are read by the existing start-up statistics probe, so default programs keep their previous code layout: paired pinned runs of the previous and current runtime show fib within noise and no workload regressing by more than 2%. The report records the interleaved measurements, the separate effects of the floor and the margin, the frontier-creep traces, the layout audit and the tested invariants.

  • Main as native (report): when every top-level binding was demoted to a main local and every value and operation is an Int, Bool or Ptr machine word, main's statements compile to native-word code instead of tagged code. Words are the fat payloads themselves, so the only boundary is print, which boxes its arguments and calls the runtime. The collatz top-level loop drops from 94.75 to 47.48 ms (−49.9%) on the cross-language suite; fib's native main is inside the spread because its work is one call, and the suites that use Float, strings, lists, maps, structs or closures keep the tagged main unchanged. --no-opt, --raw, the tagged fallback and tests/main_native_words.may (with the tagged-fallback companion tests/main_native.may) plus the oracle test cover the boundaries, and backends.py asserts the native path is taken: its image differs from the tagged build and carries the immediate-typed print boxing sequence.

  • Enum payload reads in match (report): a variant pattern proves the tag, so the tag and its payload bindings are read by guarded fixed slot instead of one rt_map_get call per arm; the runtime probe stays for Any/grown/foreign values and Result patterns. A recursive-enum evaluator drops from 7007 to 1369 ms (5.1x) and a match loop from 610 to 164 ms (3.7x), with identical output; both paths are off under --no-opt, enum_payloads.may is pinned in the oracle suite, and an objdump assertion covers the generated code. Refs #134.

  • Inline fixed-slot record construction (report): a struct or enum constructor's rt_struct_new header writes and its rt_struct_set slot writes are emitted as one generated block when the record size is a compile-time constant, while the allocation itself stays a runtime call. The heap layout is unchanged (kind-4 record block, entries at p + 48), MAYC_GC_STATS counters are identical on every workload, and --no-opt keeps the runtime calls. Binary trees drop from 975 to 803 ms of CPU (-17.7%), 2M constructions from 93 to 72 ms (-22.9%) and the record-churn workload by 20-27%; n-body and the field-read controls are unchanged. The compiler's own self-compile is 0-6% slower depending on the method and peaks up to ~2% higher, a conservative-retention effect of building the compiler with the change. tests/record_construct.may and the oracle test cover the paths.

  • Native Float functions (report): a straight-line function whose parameters, result, locals and operations are Int, Float, Ptr or Bool now compiles to native-word machine code. A Float is its binary64 bit pattern in a word, so the word call ABI, fat entry and word adapters are unchanged; inside the function XMM8-15 hold the Float locals and XMM2-7 the Float temporaries, and + - * / and the six comparisons run as SSE with the runtime's division-fault and NaN rules. Call-bound Float helpers are 3-53% faster (26-53% for expressions wider than one multiply), including to_float, which was a runtime call. A Float body that contains a loop stays tagged, so the cross-language Mandelbrot and n-body numbers are unchanged; the compiler image grows 2.4%, and this commit alone costs about 10% compiler self-compile (absorbed on the branch, where the net self-compile is faster than before). tests/native_floats.may and the oracle test cover the semantics.

  • Value propagation, dead code and block-local CSE before the fat backend (report): src/ir_opt.may propagates copies, eliminates repeated field and element reads in a straight-line region with alias-aware invalidation, removes dead definitions, stores, overwritten copies and unnamed labels, and trims the emitted frame. n-body drops from 113.6 to 94.8 ms (-16.5%) on the pre-phase-2 base, the compiler's own image shrinks 7.7% and its self-compile is 1.8% faster; the other workloads are inside the spread. Functions with an exception region keep the old path, and --no-opt skips the module; tests/ir_opt.may and the oracle test cover it.

  • Inline map probing and the ?? fast path (report): m[k] with a receiver the checker proved a Map and a key proved Str or Int walks the runtime's hash table inline, keeping rt_index_get for non-map receivers, dynamic Any values, other key types, maps below the hash-table threshold and every other case. A ?? whose indexed value is read only by the coalesce's copy and branch takes that branch from the value the probe loaded, with no temporary round trip; the nil test stays because a present entry can hold nil through an Any alias. The hashmap workload drops from 110 to 103 ms (-6.9%) and a probe-heavy workload from 240 to 182 ms (-24.1%); the sieve and string controls are unchanged (their executables are byte-identical). Both paths are off under --no-opt, and tests/map_probe.may plus the oracle test cover them.

  • Direct calls with register arguments (report): a call to a function known at compile time with matching arity passes up to three fat arguments in the register pairs RDX/RAX, RDI/RSI and R8/R9, and a native-word callee's payloads in the SysV argument registers, instead of building the 16-byte argument vector; a proven argument also skips its type check. Call-bound microbenchmarks drop 16-27%, the compiler image shrinks 2.5% and its self-compile is 1.7% faster. fib is unchanged because its recursive calls are already native-word calls, and binary trees and n-body move 1-2% because their time is allocation and map probes. Closures, function values, a mismatched arity and --no-opt keep the argument vector; tests/direct_calls.may, tests/direct_calls.py and the oracle test cover both paths.

  • Fixed-slot records and guarded slot reads (report): a struct or enum constructor builds one 48 + 32n-byte map block and writes its entries directly, so construction allocates once and hashes nothing (binary trees 1.70x, 2M two-field constructions 1.85x, a record-churn workload 1.71x, self-compile 1.20x faster). The strict checker records each field's entry slot, and a field read on a statically known struct is a guarded offset load; a grown, compacted or foreign record falls back to the field-cache probe. The collector gains a record block kind so a record's moved entries block and hash table stay traced (the cause of the reverted prototype's timing-dependent crash). A duplicate-key declaration keeps the map path. Both paths are off under --no-opt; record_layout.may, record_dup_keys.may, the GC record probe and a reduced-heap record churn cover them. Refs #134.

  • Inline push and string equality (report): a push into a list with spare capacity stores the element at its kind's width and bumps the count, falling back to rt_push for growth, a widening element type and non-list receivers; ==/!= on two strings of different byte lengths answer without entering rt_eq. The sieve's 10M push loop drops from 250 ms to 187 ms (-25%); the string workload is inside the spread and the hashmap control is unchanged. Both paths are off under --no-opt, and tests/inline_push.may plus the oracle test cover them.

  • Audit the rest of the runtime library and remove its remaining superlinear and allocation-heavy paths (report):

    • sort is a stable merge sort (O(n log n) comparisons), and unique records seen values in a map instead of scanning the result.

    • str of a list or map allocates its text once and fills it with one copy per part (as join does) instead of concatenating per element, and map display sorts its keys by merge instead of by insertion.

    • trim, int, parse_int, reverse, starts_with/ends_with, pad_left/pad_right and the JSON reader and writer no longer index code points in a loop (char_at re-walks the string from byte 0) or concatenate per character; the JSON scanner works in byte offsets.

    • rt_str_eq compares eight bytes per step, and keys/values fill the result list directly.

    • Measured on the new runtime_paths workloads, a 50 000-character trim drops from 7 032 ms to 2.0 ms, json_parse of a 20 kB document from 615 ms to 1.5 ms, str of a 20 000-element list from 1 312 ms to 6.5 ms and sort of 10 000 Ints from 292 ms to 5.1 ms, with peak RSS down from up to 288 MiB to 19 MiB. compiler/mayc/tests/strings.py now checks the rewritten string functions against Python's code point semantics.

  • Opt-in runtime collection statistics (MAYC_GC_STATS=1). The collector counts collections, allocated bytes, live bytes after the last sweep, total pause time and the heap and resident high-water marks, and writes one parseable GC key=value line after each line of output and at an uncaught fault exit. One start-up read of /proc/self/environ decides whether to enable them; after that every counter and the CLOCK_MONOTONIC pause probe sit behind one global flag, so a normal run pays a flag test per allocation and per output write. compiler/mayc/tests/limits.py --runtime-gc-stats runs the GC cases with the variable set, adds Live MiB and Runtime pause ms columns and a runtime object to the report, and requires the runtime's collection count to equal the inline meter's. make test-limits exercises it.

  • Derive the collection threshold from the live bytes of each sweep instead of the fixed 256 MiB default: the first cycle starts at half of the nominal heap, then every sweep sets max(floor, 2 * live + margin) with a margin of one sixteenth of the nominal heap (at most 8 MiB), never below the allocation frontier plus that margin and clamped to the reservation. Empty tails are still reclaimed by rewinding the bump pointer; the threshold only lowers, nothing is unmapped. Measured with the cross-language suite (five runs; the C and Rust controls moved 7-16% between the two runs on this host, so treat the times as a spread), binary trees peaks at 218 MiB instead of 287 MiB and runs in 1847 ms instead of 1746 ms; sieve, whose flags list is 160 MiB live, keeps its RSS and runs in 331 ms instead of 433 ms. The compiler's own live set no longer fits the first threshold, so --check of main.may costs about 10% more (1.39 s against 1.26 s) and a small file around 40% more (185 ms against 130 ms) while its peak RSS falls from 89 to 56 MiB. Conservative retention, not the threshold, now bounds peak RSS on the benchmark workloads: the tree sweep still finds about 39 MiB live in a 200 MiB heap.

  • Track the cross-language suite behind the performance roadmap (#101): compiler/mayc/tests/backend/xlang.py builds the eight workloads in Maylang, C, Rust, Java, Node and CPython, requires every language to print the same output, and records median wall time and peak RSS (make bench-xlang; not a CI gate). The baseline is xlang-baseline.md.

  • Add --no-opt, which turns off the fat backend's constant and variable forwarding, proven operand types, register homes, XMM Float temporaries and the new top-level-to-main-local pass. compiler/mayc/tests/oracle.py now compiles every behaviour fixture both ways in make test-compiler and requires identical exit status, stdout and stderr, so a pass that changes behaviour fails there.

  • Top-level bindings that no function reads or assigns become locals of main instead of data words, so they keep a frame slot, can take a register home and are no longer collector roots (report). The suite shows no measurable change on its own (±3%, within the run-to-run spread): proven types had already removed the type checks, and the remaining gain needs main's body to compile as native-word code.

  • Specialized list element storage (#101 phase 2): a list literal or comprehension with a known element type stores Bool as one byte, Int as a word and Float as its binary64 bits, and a value of another type arriving through an Any alias widens the list back to 16-byte fat values, so observation is unchanged (design, report). The sieve benchmark drops from 152 MiB and 308 ms to 16 MiB and 263 ms; a List<Bool> of ten million flags now costs 10 MiB instead of 160 MiB.

Licensing

  • Add a root MIT LICENSE that covers the compiler, tools, standard library, examples and native adapters, with THIRD_PARTY_NOTICES.md listing the vendored Sokol, stb and binjnes sources plus the bundled homebrew ROM and reproducing their notices (#54). GitHub can now detect the repository license. The release archive ships both files, the VS Code extension LICENSE matches the root copy, and make check fails when a vendored source loses its attribution or the manifests drift.

Documentation

  • Doc comments are the single source of API descriptions (#100). Every declaration in stdlib/, native.may and prelude.may has a /// comment in the new doc comment standard: an imperative summary and optional Params:, Returns:, Faults: and Example: sections. The per-symbol text in docs/reference/descriptions.json and the catalog entries for native.may functions in tools/maylsp/docs/reference.json moved into those comments, and make check now fails on a missing or malformed doc comment or on duplicated text.

  • maylsp renders the doc comment sections in hover and completion, keeps indentation inside comments (so fenced examples survive), and takes signature-help parameter text from Params: items.

  • The VS Code extension highlights Maylang code in docs: may is a language alias, so hover fences are coloured; a Markdown injection grammar and a markdown-it plugin colour may and maylang fences in the Markdown editor and preview; and /// comments get their own comment.line.documentation.maylang scope with highlighted backtick spans and section names. The extension now starts the language server only once a Maylang document is open.

  • Stop describing the closed sustained-allocation report (#2) as a known crash. It does not reproduce on the fat runtime: 20 gc_stress.py seeds × 400 steps, the GC and limits suites, and five repeated runs of the trees, hashmap, strings, n-body and sieve benchmarks and of mayc compiling itself all pass with identical output. The 0.15.0 remaining limits are corrected.