Repository navigation
Conversation
…d sources as UTF-8
Mode markers leaked between modules. FPC_UNLEASHED, FPC_DELPHI and the
other mode markers are system macros shared by all modules, while the mode
itself is per module. A $MODE directive in one unit changed the shared
macro and nothing restored it for the modules compiled after it. In the
product profile this always happened: the pinned memory manager unit is
compiled first and declares {$mode delphi}, so a program built with
-Munleashed or -Mobjfpc saw neither FPC_UNLEASHED nor FPC_OBJFPC, while
the program itself was compiled in the right mode. SyncModeMacro now
brings the markers in line with the module's mode switches when a module
starts compiling and when its saved state is restored.
A resourcestring of one character outside ASCII ('é', a Hangul syllable)
is a WideChar constant, and the resourcestring parser only accepted an
AnsiChar constant: "Illegal expression" in every mode. It is now turned
into a string constant and takes the ordinary string path.
{$mode unleashed} reads a source without BOM, -Fc or {$codepage} as UTF-8.
Under the ISO-8859-1 default a two-letter Korean literal was six
characters. Unleashed is a new dialect without legacy sources to keep; the
other modes keep their historical default.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…default qualification/compiler-unleashed-mode/run_gate.py compiles and runs seven cases: mode markers with the mode from the command line and from a directive, across a unit in another mode; a one-character resourcestring outside ASCII with and without -Fc; the UTF-8 default of unleashed mode; and Delphi mode keeping its historical default as a control. Expected values are Unicode code points, not the current compiler's output. Before the fix four of the seven fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An interpolated string with arguments was written with WriteStr into an
AnsiString temporary. In a Unicode string profile every non-ASCII fragment
then went through the ANSI code page: $'{N}건 조회했습니다.' came out as
thirteen characters of broken text instead of ten. The temporary is now a
UnicodeString when the default string is Unicode, an AnsiString otherwise.
qualification/compiler-unleashed-mode: interpolated-string-unicode (code
points, fails before the fix).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Added f495f2f Build interpolated strings in |
…roperty initializers
- An if / case expression whose branches are string constants was typed
ShortString (branch_type promoted two chararrays to cshortstringtype, a
char with a chararray to AnsiString). A 300-character constant came out as
255 characters, and in a Unicode string profile '한글' went through the
ANSI code page, with warning 4104 at every use. Such branches now have the
type `string` has in the mode (UnicodeString in unleashed, AnsiString
under {$H+}, ShortString otherwise).
- A class with auto-property initializers (property Width: Integer = 800;)
and no constructor of its own is given an inherited constructor to run
them in. Only the direct parent's constructors were copied: a TPersistent
descendant got none (TObject.Create is two levels up) and kept 0.
add_missing_ancestor_constructors_intf takes the constructors of every
ancestor that a closer one does not hide by name.
qualification/compiler-unleashed-mode: statement-expression-string,
auto-property-no-constructor.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Added 3b1d8ff String type of if/case expressions, inherited constructors for auto-property initializers:
🤖 Generated with Claude Code |
|
Could you submit the mode-marker fix and the single-character resourcestring fix together in a small, separate PR, with their regression tests? Both fix existing compiler bugs and are useful independently of the language changes.
The ten gate cases on
Please keep the proposed UTF-8 default for Unleashed in a separate language-change PR so it can be evaluated on its own. |
Three fixes found while building a product on
-Munleashed, plus a gate for them.1. Mode markers leaked between modules
FPC_UNLEASHED,FPC_DELPHI,FPC_OBJFPC, ... are system macros shared by all modules, while the mode itself is per module. A$MODEdirective in one unit changed the shared macro, and nothing restored it for the modules compiled after that unit.In the product profile this happened every time. The pinned memory manager unit is compiled first and declares
{$mode delphi}. As a result:-Munleashedsaw noFPC_UNLEASHED(the Unleashed docs say-Munleashedsets it the same way as the directive).-Mobjfpcsaw noFPC_OBJFPC.In both cases the program itself was compiled in the right mode. The
-vatrace shows where it happens:SyncModeMacro(scanner) now brings the markers in line with the module's mode switches at two points: when a module starts compiling (compile_module) and when its saved state is restored (tglobalstate.restore). The marker code thatSetCompileModeused to inline is now this one routine.2. A one-character resourcestring outside ASCII was rejected
A one-character literal outside ASCII is a WideChar constant, and the resourcestring parser only took an AnsiChar constant. It is now turned into a string constant and takes the ordinary string path. This failed in every mode.
3.
{$mode unleashed}reads sources as UTF-8 by defaultWithout a BOM,
-Fcor{$codepage}, sources are read in ISO-8859-1, so'한글'is six characters. Unleashed is a new dialect with no legacy sources to keep, so it now reads UTF-8. An explicit code page still wins, and the other modes keep their historical default (the gate checks that Delphi mode is unchanged). A sentence inunleashed/docs/README.mddocuments this.This one changes behaviour, so please treat it as a proposal. If you prefer, it can be dropped from the PR without affecting 1 and 2.
Verification (Win64)
qualification/compiler-unleashed-mode/run_gate.py(new, 7 cases, expected values are code points)MOONBOT_BUILD_OKqualification/pinned-unit/run.ps1RTL-test/run.py, all sources and modesmainon the same machine. The two failures are the same onmain(core_semanticdebug fails on ANSI code page 949, andwin64_trailing_call_semantic)Independent of #4 (dynamic packages).
🤖 Generated with Claude Code