hotfpc
Guides

Edits and what they do

Every kind of edit hotfpc has a test for, and what it does. Each row is a step of one of the scenarios in tests/scenarios/scenario.py: a small program that runs while the test saves the edit into it, run by CI on pull requests and on pushes to main. The outcomes are from runs of all 47 scenarios on Linux x86-64 with fpc 3.2.4 on 2026-11-26, and they are what check.py expects on macOS and Linux. Where a Windows program ends differently, the row says so.

In a swap, the program keeps running with its state; in a restart, hotfpc starts it over with the new code (What a save does).

Routines

EditOutcomeScenario
The body of a virtual methodswapclasses
A class gains an override of a virtual method its parent declaresswapclasses
New code tests the class of an object old code made (is)swapclasses
The body of a method called through an interface reference the program has held since it startedswapinterfaces
New code queries an old object for an interface (Supports) and drops the reference, so the destructor runsswap; restart on Windows, where the program was linked without Supportsinterfaces
The body of a generic method, specialised in a unit and in the main programswapgenerics
The body of an inline function that the running main block and a unit both inlinedswap, with a note that the main block keeps its old codeinline
Area(w) becomes Area(w, h), and its callers pass two argumentsswap, with a note that the old Area stays for callers that weren't compiled againsignature
Three bodies, while the main block holds procedure variables and a method pointer taken before the swap, one of them of a routine declared only in the implementation sectionswap: all three call the new codeprocvars
That routine is declared in the interface too, with another bodyswap: the procedure variable calls the new codeprocvars
Its declaration in the interface is removed again, with another bodyswap: the procedure variable calls the new codeprocvars
Locals around those a nested routine reads, and another body for it, while its parent runs across the swap and calls itswap: the running parent keeps calling the old nested routine, with its own valuesnestedframe
New code raises an exception that the old main block catchesswapexceptions
New code makes the runtime raise (StrToInt of a word) and catches itswapexceptions
New code shrinks an array, cuts a string and frees a list that old code allocatedswapheap

Constants and variables

EditOutcomeScenario
Rate = 1.5 becomes Rate = 2.5swap: the new value is used at onceconstants
A new constant, used before the othersswapconstants
A new variable with an initial valueswapglobals
Speed: Integer = 5 becomes = 50, and Speed still holds 5swap: Speed is 50, with the note U.SPEED still had its initial value; set to the new oneglobals
Total: Integer = 0 becomes = 1000, and the program has changed Total from 0swap: Total keeps its value, with the note the initial value of U.TOTAL changed; the running value is keptglobals
Speed: Integer = 5 becomes = 50 and a 16-byte record Pair = (A: 1; B: 2) becomes (10, 20), and a write to each lands while the swap loads (HOT_TEST_DATA_WRITE makes it)swap: both keep the program's values, each with the note the initial value of U.<name> changed; the running value is keptinitrace
Hidden: Integer becomes Hidden: Int64restart: u.Hidden: the declaration changed its layout or typeglobals
Calls: Integer in the implementation section becomes Calls: Single, the same sizerestart: u.Calls: the declaration changed its layout or typehidden
Calls: Integer = 0 in the implementation section becomes Int64 = 0restart: u.Calls: the declaration changed its layout or typeinitvar
The typed constant Calls: Integer = 0 becomes Int64 = 0restart: variable U.CALLS changed size from 4 to 8 bytestypedconst
Another text in the program file, saved while fpc can't write the program's assembler (.hot/asm/main.s is a directory)swap; on Windows, restart: the sizes of variables with initial values are unknown: <fpc> did not compile the program to assembler (...)progvar
Calls: Integer = 0 in the program file becomes Int64 = 0restart: variable MAIN.CALLS changed size from 4 to 8 bytes, also on Windows after the save beforeprogvar
A save removes Calls: Integer = 0 and its uses from the program fileswapreaddvar
A later save adds Calls: Int64 = 0 backrestart: variable MAIN.CALLS changed size from 4 to 8 bytesreaddvar
Then Calls: Integer = 0, its first typeswap: Calls counts on from the value it had, with the note MAIN.CALLS is back after a save removed it; it keeps its running valuereaddvar
A save removes Hits: Integer from a unit's interface and Calls: Integer from its implementation section, with their usesswapreaddtype
A later save adds both back as Single, the same sizerestart: u.Hits: the declaration changed its layout or type, and the same for u.Callsreaddtype
Then both as Integer, their first typeswap, with the note U.HITS is back after a save removed it; it keeps its running value, and the same for U.CALLSreaddtype
A typed constant in a routine, Calls: Integer = 0, becomes Int64 = 0restart: variable U.TICK(LONGINT):ANSISTRING.CALLS changed size from 4 to 8 byteslocalconst
Small: Word = 1 in the program file, before Big: Int64 = 2, becomes LongInt = 1: it grows within the padding before Bigrestart: variable MAIN.SMALL changed size from 2 to 4 bytespadvar
Then Small is a Word again, and Flag: Byte, before Wide: Int64, becomes Wordrestart: variable MAIN.FLAG changed size from 1 to 2 bytespadvar
Then Flag is a Byte again, with a new Flag2: Byte after itswappadvar
A save removes Small and its usesswappadvar
A later save brings Small back as LongInt = 1, with its usesrestart: variable MAIN.SMALL changed size from 2 to 4 bytespadvar
The first three of those saves in a unit's implementation section, without the check of layouts (--ppudump names a ppudump that doesn't exist)restart, restart and swap: variable U.SMALL changed size from 2 to 4 bytes, then variable U.FLAG changed size from 1 to 2 bytespadunit
Then Shared: Word = 1 in the unit's interface, before SharedNext: Int64, which only the program's code uses, becomes LongInt = 1: on macOS the unit's object file comes out the samerestart: variable U.SHARED changed size from 2 to 4 bytes, also on Windows, where the unit's COFF object comes out the same toopadunit
Shared: Integer in a unit's interface, which only the program's code uses, becomes Single, the same size: the unit's object file comes out the samerestart: u.Shared: the declaration changed its layout or type, with a ppudump that reads the units; without one, swapsharedtype
Shared: Integer in a unit that only another unit's code reads becomes Single, with an error in the programthe compile failsdropunit
Then the error is gone, and the unit that read Shared no longer uses the first oneswap: the first unit's unit file from the failed compile is gonedropunit
Then it reads Shared again, now a Singlerestart: u.Shared: the declaration changed its layout or typedropunit
Then it no longer uses the first unit againswap: the refused unit file is gone toodropunit
A comment in a unit with a variable with an initial valuenot swapped: the generated code is the samerecheck
Then another text in another unit, which has no variable with an initial value, while fpc can't write the program's assemblerswap: the unit with the comment isn't checked again, also on Windowsrecheck

The program's variables keep their values through every swap: the scenarios globals and hidden check that a counter in a unit's implementation section keeps counting.

Records, classes and interfaces

EditOutcomeScenario
A record's field y: Integer becomes y: Single, the same sizerestart: u.TPos: the declaration changed its layout or typerecords
A record gains a fieldrestart, the samerecords
A class gains a fieldrestart, for the class and each class derived from itclasses
A class gains a virtual methodrestart: class U.TANIMAL: the virtual method table changed from 27 to 28 slots, and the same for each derived classclasses
Two fields of a class in the interface section swap places, the instance size the samerestart: u.TPair: the declaration changed its layout or typehidden
Two fields of a class in the implementation section swap placesrestart: u.THidden: the declaration changed its layout or typehidden
An interface gains a methodrestart: type U.IGREETER: its layout or type information changedinterfaces

Units, threads and include files

EditOutcomeScenario
An include file used by two unitsswap, of both unitsinclude
A constant in an include fileswap, of both unitsinclude
A save that empties one file first and writes it 0.3 s later, with another file written meanwhileone swap, of both, once the file is writteninclude
The initialization section assigns something elseswap, with the note the initialization section of u changed; it is not run againinitfinal
The finalization section prints something elseswapinitfinal
The program now uses a new unit of its ownrestart: unit extra is not part of the running programnewunit
A unit now uses Math, a unit of the runtime the program wasn't linked withrestart: u uses MATH.POWER(EXTENDED,EXTENDED):EXTENDED, which the running program does not containnewunit
New code calls functions of SysUtils the program never calledswap; restart on Windowsnewunit
u.pas becomes w.pas, and the program uses wrestart: unit w is not part of the running programrename
Another text, with a thread variable untouchedswapthreadvars
A second thread variablerestart: the thread variables of unit u changedthreadvars
Another text, and Speed: Integer = 5 becomes = 50, while a thread of the program blocks every signalswap, within the scenario's limit of 1 s inside the program: Speed is 50signals

Restarts

These scenarios let hotfpc start the program over; the others pass --no-restart.

EditOutcomeScenario
Calls: Integer becomes Int64, with another textrestart, then the program runs the new code and counts from 1restart
Another text, after that restartswap, into the restarted programrestart
A unit uses a new unit whose code calls a routine no library hasrestart, but the link fails: fpc's errors, and the program carries on with its old codelinkfail
The new unit no longer calls itrestartlinkfail
Calls becomes Int64, and the initialization section ends the program with exit code 3restart; the new program fails, and hotfpc waitscrash
The initialization no longer ends itthe next save starts the program againcrash
An assembler routine of 3 bytes, packed right before the next with {$codealign proc=1}, returns another valuerestart on x86-64 macOS and Linux: U.SMALL:LONGINT is 3 bytes from the next routine, too close for the 5-byte jump to its new code; swap on arm64 and Windows, where the jump fitsshortentry
An assembler routine whose first instruction, 2 bytes long, calls a routine a thread waits in returns another valuerestart on x86-64 macOS, Linux and Windows: U.RELAY(POINTER,POINTER):LONGINT may call a routine within its first 5 bytes, and a thread could return from it into the middle of the jump to its new code; swap on arm64, where the call returns after the jumpshortcall
A thread traps in an assembler routine's first bytes and its signal handler, or on Windows its vectored exception handler, waits until new code runs; the routine returns another valuerestart on x86-64 macOS, Linux and Windows: a thread may resume within the first 5 bytes of U.ENTRY:LONGINT, in the middle of the jump to its new code, such as one a signal or an exception interrupted there; swap on arm64, where the thread resumes after the branchsighandler
The same, with a signal handler that blocks every signal: on Linux the agent can't stop the thread, and reads its stack where it sleepsthe samesigmasked

Saves in quick succession

EditOutcomeScenario
Two saves 0.12 s apart, twiceeach save is swapped, or two are compiled together; the program shows the newest text either wayrapid
One save whose second file is written while fpc compiles the firstcompiled again once the files settle, then swapped onceslowsave
Calls: Integer = 0 in the program file becomes Int64 = 0, with another text, saved while hotfpc builds the program to start it, after fpc has read the filebuilt again before the program starts: the program runs the save from its first tickstartsave
Another text, after that startswapstartsave
Another text, saved during the first build while fpc can't write the program's assembler, and another during the build that followsbuilt again each time: the program runs the second from its first tickstartblock
Calls: Integer = 0 in the program file becomes Int64 = 0, after that startrestart: variable MAIN.CALLS changed size from 4 to 8 bytesstartblock
Saves during each of the first four builds, the last of which makes Calls: Integer = 0 Int64 = 0the fourth build is used as it is: the program runs the third savestartcap
That save, compiled once the program runs, and another textrestart: variable MAIN.CALLS changed size from 4 to 8 bytes; on Windows the sizes of variables with initial values are unknown: the sources changed while fpc compiled them, for one or both savesstartcap
Saves during each of the first four builds, as in startcap, while fpc can't write the program's assembler for the fourththe fourth build is used as it is; on Windows its sizes are unknown, and hotfpc says sostartnoasm
The save that grew Calls, compiled once the program runs, and another text once fpc can write the assembler againrestart: variable MAIN.CALLS changed size from 4 to 8 bytes; on Windows the sizes of variables with initial values are unknown: <fpc> did not compile the program to assembler (<problem>), for one or both savesstartnoasm
Another text, saved while hotfpc builds the program to start it, by an editor that empties the file and writes it 0.3 s laterbuilt again once the file is written: the program runs the save from its first tickstartempty
Another textswapstartempty
The program no longer uses a unit, saved while hotfpc builds the program to start itbuilt again before the program starts: the program starts without the unitstartunit
The program uses that unit againrestart: unit w is not part of the running programstartunit
A unit the program uses gets a new unit with a typed constant, Limit: Integer = 7restart: unit w is not part of the running programnewconst
That constant becomes Limit: Int64 = 8restart: variable W.LIMIT changed size from 4 to 8 bytesnewconst

Running one yourself

./build.sh hotfpc
python3 tests/scenarios/check.py records

check.py prints one line per scenario and the run of each one that failed. Testing explains the scenarios and how to add one.

On this page