Skip to content

Code Review from my AI Buddy for the compiler #31

Description

@stvowi

I reviewed the unleashedpascal/compiler source. Since the repo is a fork of Free Pascal (37 MB, ~27,000 files), I focused the review on the actual fork-specific delta — using git history to find the fork point, then reviewing the diff for the ~28 most heavily modified core compiler files (covering ~25,000 of the ~26,300 changed lines), where all of Unleashed Pascal's new language features live.

The review found 24 actionable issues, including:

1 Critical: PreInc/PreDec can read through an already-released temp on complex operands (e.g. PreInc(arr[idx()])), a genuine use-after-release bug that can silently corrupt results.

7 High-severity issues, e.g. embed T; never rejects a flexible-array-member record (silent memory-layout corruption), array/tuple equality re-evaluating side-effecting operands multiple times, procvar devirtualization lacking a dominance check (can call the wrong function), autofree/defer crashing the compiler inside a unit's initialization section, and $''' interpolated triple-quote strings not being rejected as documented.

1 medium-high issue: undocumented &=/|= operators silently active in every language mode, a backward-compatibility hazard.

8 medium and 6 low severity issues covering match, for parallel, generics, string interpolation, and compiler options.

The report also documents ~20 higher-risk areas that were specifically checked and found correct — including the project's own two flagged risk areas (FPC_UNLEASHED/FPC_OBJFPC exclusivity and default modeswitch wiring) — so it's clear what was verified rather than skipped.

Each finding includes the exact file/function, a description of why it's a bug, severity, and a suggested fix, with links into the repository. The full report has been saved to your Unleashed Pascal project and shared above.

Unleashed Pascal Compiler — Code Review.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions