Skip to content

[CSGen] Always record types of variables introduced by named patterns #38511

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Sema/CSGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2217,6 +2217,8 @@ namespace {
// If we have a type to ascribe to the variable, do so now.
if (oneWayVarType)
CS.setType(var, oneWayVarType);
else
CS.setType(var, varType);

return setType(varType);
}
Expand Down
6 changes: 6 additions & 0 deletions test/Constraints/patterns.swift
Original file line number Diff line number Diff line change
Expand Up @@ -514,3 +514,9 @@ func rdar64157451() {
if case .foo(let v as DoeNotExist) = e {} // expected-error {{cannot find type 'DoeNotExist' in scope}}
}
}

// rdar://80797176 - circular reference diagnosed while reaching for a type of a pattern.
func rdar80797176 () {
for x: Int in [1, 2] where x.bitWidth == 32 { // Ok
}
}