You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
The following code crashes the compiler with “SIL verification failed: external declaration of internal SILFunction not allowed: F->isAvailableExternally()”:
publicstructPoint:Sendable{publicletcoordinates:[Double]}extensionPoint{publicfunc euclideanDistance(to other:Self)async->Double{awaitsquareOfEuclideanDistance(to: other).squareRoot()}@inlinablepublicfunc squareOfEuclideanDistance(to other:Self)async->Double{letzippedCoordinates=zip(self.coordinates, other.coordinates)returnawaitwithTaskGroup(of:Double.self){ group ->Doublein
for coordinatePair in zippedCoordinates {
group.addTask{returnsquareOfDistance(between: coordinatePair)}}returnawait group.reduce(0,+)}@Sendablefunc squareOfDistance(between coordinatePair:(Double,Double))->Double{letdistance= coordinatePair.0- coordinatePair.1return distance * distance
}}}
I’m not able to further reduce the code, but I noticed that the compiler doesn’t crash if either of these 2 changes is made to the code example:
Remove public from Point’s declaration.
Remove @inlinable from squareOfEuclideanDistance’s declaration.
Normally, it seems to work well to use a local function before its declaration, but the problem occurs specifically when the local function is declared after the return statement that uses it in an inlinable function.
Should it even be valid to use a local function before its declaration?
I was distracted by toggling public and @inlinable, and wasn't able to make the example code simpler. Thanks for further reducing it!
This pitch from a year ago by @slavapestov suggests that it should be valid to use a local function before its declaration. Even if it should be invalid, then the behaviour should be consistent whether or not the outer function is public or @inlinable.
I think it should be valid, and I see that's what your fix is in the PR.
Thanks for your reply! I didn't know about that pitch yet, but indeed I assumed that it should be valid (just like it is for local structs). Indeed, it turns out that my PR is in line with the proposal, so that's good news 🙂
It would be great if someone could start the CI for my PR, because it seems I don't have permission to do so myself.
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
Attachment: Download
Environment
macOS 12.1 Beta (21C5021h)
Xcode 13.2 beta 2 (13C5081f)
Swift Development Snapshot 2021-11-20 (a)
Additional Detail from JIRA
md5: b8e359859c2ecdc36022925c041ff831
blocks:
Issue Description:
The following code crashes the compiler with “SIL verification failed: external declaration of internal SILFunction not allowed: F->isAvailableExternally()”:
I’m not able to further reduce the code, but I noticed that the compiler doesn’t crash if either of these 2 changes is made to the code example:
Remove
public
fromPoint
’s declaration.Remove
@inlinable
fromsquareOfEuclideanDistance
’s declaration.The crash log is here: https://gist.github.com/WowbaggersLiquidLunch/c6e1d931bc184937c557e985ec8d4d92
A package containing the code is attached to this report.
The text was updated successfully, but these errors were encountered: