issues: file 0060 — closure-literal composition miscompiles (blocks ERR/E5.1)

Probing ERR/E5.1 (composition with closures) surfaced pre-existing closure-
literal lowering bugs: a closure literal passed as a function-type argument and
called inside the callee returns wrong values (block-body 192, arrow-body 20,
want 10 — non-failable too; the working contrast passes the value as a separate
arg, examples/0302). On top of that, failable closure returns don't parse
(isLambda omits .bang — one-line fix in the issue) and arrow-body failable
closures miscompile (return 0); block-body failable closures called directly
work. Runnable repro + parser patch + investigation prompt in the issue.

E5.1 paused per the impassable rule rather than built on miscompiling closures;
the parser fix + a regression example were reverted to avoid landing silently-
miscompiling failable closures on master.
This commit is contained in:
agra
2026-06-01 20:18:25 +03:00
parent 549f97c731
commit 485b4fa618
4 changed files with 112 additions and 4 deletions

View File

@@ -15,7 +15,7 @@
#import "modules/platform/types.sx";
#import "modules/platform/api.sx";
UIApplicationMain :: (argc: s32, argv: *void, principal_class: *NSString, delegate_class: *void) -> s32 #foreign;
UIApplicationMain :: (argc: s32, argv: *void, principal_class: *NSString, delegate_class: *NSString) -> s32 #foreign;
dlsym :: (handle: *void, name: [*]u8) -> *void #foreign;
chdir :: (path: [*]u8) -> s32 #foreign;
@@ -200,7 +200,8 @@ UITextField :: #foreign #objc_class("UITextField") {
init :: (self: *Self) -> *UITextField;
}
// SxAppDelegate — UIApplicationMain's principal class. Method bodies
// SxAppDelegate — UIApplicationMain's delegate class (the app delegate, a
// UIResponder — NOT the UIApplication principal class). Method bodies
// dispatch to UIKitPlatform methods on the shared `g_uikit_plat`.
SxAppDelegate :: #objc_class("SxAppDelegate") {
#extends UIResponder;
@@ -364,7 +365,13 @@ impl Platform for UIKitPlatform {
self.has_frame_closure = true;
g_uikit_plat = self;
inline if OS == .ios {
UIApplicationMain(0, xx 0, xx "SxAppDelegate", xx 0);
// (argc, argv, principalClassName, delegateClassName). SxAppDelegate
// is the DELEGATE (a UIResponder), not the UIApplication subclass —
// pass nil for the principal so UIKit uses the default UIApplication.
// Passing it as the principal makes newer UIKit call UIApplication
// class methods on it (e.g. `+registerAsSystemApp`) → unrecognized
// selector crash during UIApplicationMain prep.
UIApplicationMain(0, xx 0, xx 0, xx "SxAppDelegate");
}
}