Skip to content

Type-checker OOM (16-32 GB allocation) on deeply-nested str_concat / format chains #1

@hyperpolymath

Description

@hyperpolymath

Symptom

my check on a .my file with many deeply-nested str_concat chains and/or many multi-line format() templates triggers a runaway memory allocation (16-32 GB observed) and OOM-aborts the process:

my.exe : memory allocation of 34359738368 bytes failed
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The same happens on my run of the same file (the type-checker runs first).

Reproducible against

A non-trivial Solo program with ~30 inline template-emitter functions, each containing chained str_concat/format() calls, totalling ~330 LOC. Stripped down to ~110 LOC (audit logic only, no template builders), the same file type-checks and runs in <1s.

The trigger appears to be aggregate complexity of nested string-building constructs, not any single construct. A minimal pathological case I could not narrow further in this session.

Approximate repro shape

fn build_a(name: String, lang: String) -> String {
    return str_concat(
        str_concat(
            str_concat(
                format("// SPDX-License-Identifier: PMPL-1.0-or-later\n= {}\n:toc:\n\n", [name]),
                format("Component: {} ({}).\n\n", [name, lang])
            ),
            format("== Status\n\nStandalone. Conforms to the standards.\n\n* RSR template floor.\n* Stapeln container build using {}.\n* Contractiles.\n* 6a2 machine-readable.\n\n", [lang])
        ),
        "\n== License\n\nPMPL-1.0-or-later.\n"
    );
}

// ... 27 more functions of similar shape ...
// Combined file -> OOM during `my check`

Environment

  • my-lang HEAD: as of 2026-04-30 (with locally-applied stdlib additions for fs_*/env_args/format — see paired PR)
  • Toolchain: stable-x86_64-pc-windows-msvc, rustc 1.95.0
  • OS: Windows 11 Pro for Workstations 26300

Suspected cause

Type-checker likely has a non-memoised recursion over the AST of str_concat/format chains, producing exponential type-resolution cost. A minimal Array mismatch returns a clean TypeMismatch error in microseconds, so the OOM is specifically a complexity issue, not parser-level construct rejection.

Suggested fix direction

  • Memoise type checks on common subexpressions (especially repeated str_concat/format AST nodes).
  • Add a depth/size guard with a clear error when exceeded, rather than letting the allocator OOM.

Workaround in use

For the project that surfaced this (an idaptik scaffold tool), templates were moved out of .my source and into on-disk template files, read at runtime via fs_read_file + format(). The reduced AST type-checks fine.

Why this matters

This blocks using Solo for tooling that emits templated output (scaffolders, codegens, doc generators). Until fixed, every such tool has to use the on-disk-template workaround, which is a real ergonomic tax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions