Skip to content

[SR-16088] Parameterized result builder breaks type inference #58347

@stephencelis

Description

@stephencelis
Previous ID SR-16088
Radar None
Original Reporter @stephencelis
Type Bug
Environment

Xcode 13.3 / Swift 5.6

(Also fails with 2022-03-22 snapshot)

Additional Detail from JIRA
Votes 4
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: cfd91f8a83f3d37d1340e06d4b9d8b10

Issue Description:

The following gist has 2 versions of similar code. The main difference (shown in a diff) is that one result builder is parameterized with a generic that is used to constrain its "buildExpression" to help with type inference, the other is not parameterized.

https://gist.github.com/stephencelis/e6fa9caed1daa054e24e9d23c186bf2d

The code is a simplified parsing DSL that should automatically skip "Void" outputs (much like the Regex DSL being currently worked on). Unfortunately, parameterizing the result builder allows things to compile that shouldn't: the unparameterized version ensures "Void" outputs never make their way into the final parser, while the parameterized version allows these values to make their way through.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions