serenity icon indicating copy to clipboard operation
serenity copied to clipboard

AK: Work around Xcode 15 beta mishandling trailing `requires` clauses

Open BertalanD opened this issue 2 years ago • 2 comments

Xcode 15 betas 1-3 lack https://reviews.llvm.org/D135772, which fixes a bug that causes trailing requires clauses to be evaluated twice, failing the second time. Reported as FB12284201.

This caused compile errors when instantiating types derived from RefPtr:

error: invalid reference to function 'NonnullRefPtr': constraints not satisfied note: because substituted constraint expression is ill-formed: value of type '<dependent type>' is not contextually convertible to 'bool'.

This commit works around the issue by moving the requires clauses after the template parameter list.

In most cases, trailing requires clauses and those specified after the template parameter list, so this change should not impact the code's behavior. The only difference is that trailing requires clauses are evaluated after constrained placeholder types (i.e. Integral auto i function parameter).

BertalanD avatar Jul 10 '23 15:07 BertalanD

Should we land workarounds for beta software? Maybe it'll be fixed in the stable release.

nico avatar Jul 11 '23 17:07 nico

The way I see it, this workaround is zero-cost: we are not adding any extra logic or inefficiency to our code; and it's not just me that has run into this. Having this superficial issue fixed will allow for more people to beta-test Xcode for Ladybird, which will let us discover more serious issues (like the addc miscompile) more likely.

BertalanD avatar Jul 11 '23 17:07 BertalanD

From the commit message:

In most cases, trailing requires clauses and those specified after the template parameter list, so this change should not impact the code's behavior.

I think there's something missing from the first part of this sentence?

AtkinsSJ avatar Jul 12 '23 06:07 AtkinsSJ

🤦 should be fixed

BertalanD avatar Jul 12 '23 07:07 BertalanD

This seems harmless enough. Might be tricky to avoid letting more of these show up, but we don't use requires that often, so it's probably fine.

AtkinsSJ avatar Jul 12 '23 14:07 AtkinsSJ