blaise/compiler
Graeme Geldenhuys a903c83c89 feat(lang): enforce visibility on bare static-var access too
The initial visibility pass checked the qualified form (TFoo.StaticVar) but not
the bare unqualified form, which resolves to the same shared global.  A
strict-private static var was therefore still reachable by name from another
type, the program body, or a unit's initialization section — contrary to the
design (a strict-private member is reachable only from its declaring type's own
methods).

Enforce member visibility at the bare static-var read (AnalyseIdentExpr) and
write (AnalyseAssignment) sites, and at the qualified read (AnalyseFieldAccess),
matching the qualified-write site added earlier.

A static method leaves FCurrentClass nil (so implicit-Self refs fail cleanly),
which would wrongly reject a strict-private static var accessed from its own
type's static method — the singleton's `static function TFoo.Instance` reading
bare FInstance.  Track FCurrentMethodOwner (the declaring type of the current
method body, set for static and instance methods alike) and use it as the
"from" class for static-var visibility via the new AssertStaticVarVisible, so
own-type static methods keep access while non-method contexts (program body,
unit init/final) do not.

Adds cp.test.visibility cases for bare-from-other-type, from-program-body, and
non-strict-private-from-program-body (the unit-init-scope analogue), plus a
public static var qualified cross-type read.
2026-06-29 00:10:48 +01:00
..
src feat(lang): enforce visibility on bare static-var access too 2026-06-29 00:10:48 +01:00
project.xml refactor(rtl): relocate RTL units into the compiler tree (dotted-flat names) 2026-06-25 16:05:44 +01:00