Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sema]Set IsSending flag to subscript.getter if needed #79042

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stzn
Copy link
Contributor

@stzn stzn commented Jan 30, 2025

Resolves #79041

When using the sending keyword in a subscript parameter through protocol conformance, an assertion failure occurs when emitting SIL.

For example, run the following code with swift -frontend -emit-sil -swift-version 6:

class NonSendable {}
protocol P {
    subscript(_: sending NonSendable) -> Bool { get }
}

struct S: P {
    subscript(_: sending NonSendable) -> Bool { true }
}

It triggers the following assertion failure:

sil_witness_table hidden S: P module main {
  method #P.subscript!getter: <Self where Self : P> (Self) -> (Assertion failed: (flags.isSending() && "Only valid when sending is enabled"), function printParameterFlags, file ASTPrinter.cpp, line 3759.

It appears we need to add a flag when the subscript parameter includes the sending keyword.

@stzn stzn marked this pull request as ready for review January 30, 2025 19:12
@stzn stzn changed the title [Parse]Set IsSending flag to subscript.getter if needed [Sema]Set IsSending flag to subscript.getter if needed Jan 31, 2025
@stzn stzn force-pushed the fix-subscipt-sending branch from 4326c5d to 65ac75f Compare January 31, 2025 21:43
@omochi
Copy link
Contributor

omochi commented Jan 31, 2025

@swift-ci please smoke test

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.

Assertion failure occurs with a sending subscript parameter through protocol conformance
2 participants