Skip to content

Conversation

@sidepelican
Copy link
Contributor

@sidepelican sidepelican commented Jan 20, 2026

When reading the following code causes the jextract command to crash.

public func f() -> Any {
    return 0
}

JExtractSwiftLib/SwiftType.swift:368: Fatal error: Unexpectedly found nil while unwrapping an Optional value

According to swift-syntax, Any is not an Identifier and thus cannot be handled by the lookup.

https://github.com/swiftlang/swift-syntax/blob/65b02a90ad2cc213e09309faeb7f6909e0a8577a/Sources/SwiftSyntax/Identifier.swift#L31

Since Any is existential, neither JNI mode nor FFM mode is currently supported. Therefore, I'll modify the implementation to simply ignore it.

@sidepelican sidepelican requested a review from ktoso as a code owner January 20, 2026 08:55
@sidepelican
Copy link
Contributor Author

Ah, I've discovered that existentials in argument position are supported in JNI mode.
I need to reconsider how Any should be represented.

@ktoso
Copy link
Collaborator

ktoso commented Jan 20, 2026

Edit with more ideas: I guess we'd have to defensively copy into a new buffer since we don't know if the value is a value or an instance to retain... that'd force us into arena use as well (tho in JNI i guess going global by defalt may be fine).

It's a tricky question, ok to leave as is for now

@sidepelican
Copy link
Contributor Author

Implementing full support for Any seems take a time.
My main focus is to avoid the fatal error, so I’d like to handle Any as unsupported.

@ktoso
Copy link
Collaborator

ktoso commented Jan 20, 2026

Yeah that works for me, thanks

@ktoso ktoso closed this Jan 20, 2026
@ktoso ktoso reopened this Jan 20, 2026
@ktoso
Copy link
Collaborator

ktoso commented Jan 20, 2026

Whoops misclicked, tests passed

@ktoso ktoso merged commit 680a3fc into swiftlang:main Jan 20, 2026
48 of 49 checks passed
@sidepelican sidepelican deleted the fix_crash_Any branch January 20, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants