ffi 3.2 C4/C5 BLOCKED: file issue-0043 — lazy lowering loses foreign-class dispatch

Per CLAUDE.md IMPASSIBLE RULES. Attempted Phase 3.2 C4 migration of
the UIKit chrome cluster in `library/modules/platform/uikit.sx`
(UIScreen / UIWindow / UIViewController / UITextField / UIView)
surfaced a real compiler bug: when a function body contains
`recv.method(...)` calls against an `#objc_class` receiver AND that
body is reached via `lazyLowerFunction` invoked from another
`inline if OS == ...` branch, the method dispatch fails with
"unresolved 'methodName'".

Specifically: `uikit_scene_will_connect_ios` (the iOS-sim crashing
case) contains `UIWindow.alloc().initWithWindowScene(scene)` etc.
The same calls compile cleanly in isolated probes — only the lazy-
lower-via-inline-if entry chain reproduces the bug. macOS target
builds fine throughout; ios-sim trips it.

C1/C2/C3 (commits 1ea9cda / 17775b2 / 2a7c8e0) happen to land cleanly
because the methods they migrate are reached eagerly (or are niladic
so the dispatch path doesn't hit the failing branch). C4 + C5 stay
blocked pending issue-0043's fix in a separate session.

Issue filed at `issues/0043-lazy-lower-loses-foreign-class-method-dispatch.md`
with the reproduction, stack trace, and investigation prompt
pointing at `lower.zig:1057` (`lazyLowerFunction`) and
`lower.zig:5290` (the field-access foreign-class dispatch chain).

FFI checkpoint updated to mark C4+C5 as BLOCKED on 0043.

The in-progress C4 working-tree changes were reverted; tree is at
the C3 commit `2a7c8e0` and chess on macOS/iOS-sim/Android builds
cleanly.
This commit is contained in:
agra
2026-05-25 17:27:29 +03:00
parent 2a7c8e0a6f
commit 15f10c5031
2 changed files with 164 additions and 2 deletions

View File

@@ -568,9 +568,29 @@ blocks. The `link` parameter on the `sxTick:` callback is now cast
to `*CADisplayLink` at function entry so subsequent method calls
type-check.
**Phase 3.2 C4/C5 BLOCKED on issue-0043.** Attempted C4 migration
(UIKit chrome: UIScreen / UIWindow / UIViewController / UITextField
/ UIView) surfaced a real compiler bug: lazy-lowered function bodies
don't resolve foreign-class method dispatch when invoked transitively
from an `inline if OS == .ios` branch in another function. The
specific failure is in `uikit_scene_will_connect_ios` whose body
contains `UIWindow.alloc().initWithWindowScene(scene)` and
`win.setRootViewController(...)` — both work in isolated probes but
fail at compile time when the function is reached via lazy lowering
from chess's iOS scene-connect hook. macOS target builds fine; only
ios-sim trips it. C1/C2/C3 happened to land cleanly because the
methods they migrate are reached eagerly (or are niladic so the
dispatch path doesn't hit the failing branch).
The C4 work is reverted to keep the tree green at C3. C4+C5 stay
pending until issue-0043 is fixed in a separate session.
Open work:
- **Phase 3 step 3.2 — C4..C5** — uikit.sx migration, two clusters
remaining (UIKit chrome, view tree + GL).
- **issue-0043** — investigate + fix the lazy-lower foreign-class
dispatch bug. See `issues/0043-lazy-lower-loses-foreign-class-method-dispatch.md`
for the reproduction and investigation prompt.
- **Phase 3 step 3.2 — C4..C5** — uikit.sx migration, blocked until
0043 lands.
test for the default-mangling table. Escape hatch for selectors
that don't fit the underscore-split rule (e.g. `tableView_
numberOfRowsInSection_` with an asymmetric keyword count).