CORPUS-TEST.md 3.3 KB

Pascal corpus census

Sources/Dezip/ is an external collection, not part of the build. It contains 4,919 .pas files (77 MB, about 354k lines). Most are SWAG/FreePascal or Delphi units, so a failure count is not a compiler score; it is a map of what the TP3 subset does not cover yet.

Method

Every file was compiled separately with the current shell/compiletest, in a fresh process and with a 5-second timeout. Separate processes matter: the first batch run aborted after a compiler bug, and one crashing source must not hide the rest of the corpus.

Current result

result count
compiles 49
errors 4,870
crashes/timeouts 0

By error code:

code meaning count
41 unknown construct/identifier 4,335
90 include file not found 418
102 not implemented 48
1 syntax / semicolon 39
30 simple type expected 20
56 type mismatch 9
99 compiler overflow 1

The useful subset is pascsrc/, which is the classic TP3 example material: 44 of 84 compile. The SWAG tree is 4,473 files, almost all FreePascal or Delphi units; only 5 compile.

Bugs found by the corpus

  • Typed constants containing an array of strings crashed the compiler. A one-character element such as 'I' is scanned as a CHAR scalar, not a string, so DefConst took the integer path and shifted a 16-bit value through divi until it became zero: SIGFPE in DefConst. The array element type is now consulted; a scalar element of a STRING array is stored as a one-character string. t118_strconstarray compiles and prints '', I, II.
  • This bug was also hit by Roman2.pas in the SWAG tree. It now gets a normal diagnostic (Word is not yet a type) instead of killing the compiler.

Main blockers visible in the census

  1. uses/unit imports. Most SWAG files cannot even reach a declaration after their uses line.
  2. The wider integer family: Word, LongInt, ShortInt, Single, Double.
  3. Turbo extras such as absolute, Printer, Dos, Mem/Msdos, and Addr beyond the currently supported pointer paths.
  4. Includes whose names or search paths differ from the file's own directory (ERROR 90, 418 files).

The 49 clean files are useful smoke material, but the corpus is intentionally not wired into run_all.sh: it lives outside the repository and most of it is outside the TP3 language subset.

Conservative cleanup

The obvious non-TP3 material was removed:

  • the whole Dezip/swag-pascal-master tree and its swag-pascal-master.zip;
  • 416 .pas files outside that tree that declare unit, use uses, or carry FreePascal/Delphi markers;
  • 42 zip archives whose Pascal entries were all marked in that way.

Mixed archives — including pascsrc.zip, which also contains the 44 compiling TP3 examples — were deliberately kept.

Before cleanup: 6,810 files, 4,919 .pas, 907 zips. After cleanup: 1,731 files, 71 .pas, 858 zips.

The remaining 71 Pascal files compile as 54 OK / 17 errors after the first compiler upgrades (long identifiers, named labels, Addr, field widths, nested arrays, negative bounds, forward pointer types, NIL, and forward procedure parameters). The remaining 17 are TP3-feature gaps, not unit/Delphi noise.