Skip to content

[TypeLowering] Fixed verifier variable shadowing. #64971

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

Merged
merged 1 commit into from
Apr 6, 2023
Merged
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
3 changes: 2 additions & 1 deletion lib/SIL/IR/TypeLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2745,7 +2745,7 @@ bool TypeConverter::visitAggregateLeaves(
Optional<unsigned> maybeIndex;
if (index != UINT_MAX)
maybeIndex = {index};
return {ty, origTy, field, index};
return {ty, origTy, field, maybeIndex};
};
auto isAggregate = [](CanType ty) {
return isa<SILPackType>(ty) ||
Expand All @@ -2761,6 +2761,7 @@ bool TypeConverter::visitAggregateLeaves(
ValueDecl *field;
Optional<unsigned> index;
std::tie(ty, origTy, field, index) = popFromWorklist();
assert(!field || !index && "both field and index!?");
if (isAggregate(ty) && !isLeafAggregate(ty, origTy, field, index)) {
if (auto packTy = dyn_cast<SILPackType>(ty)) {
for (auto packIndex : indices(packTy->getElementTypes())) {
Expand Down
6 changes: 6 additions & 0 deletions test/SILGen/lexical_lifetime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ enum E {
@_silgen_name("use_generic")
func use_generic<T>(_ t: T) {}

struct NonlexicalBox<X> {
@_eagerMove var x: X
}

////////////////////////////////////////////////////////////////////////////////
// Declarations }}
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -147,6 +151,8 @@ extension C {
func eagermove_method_attr() {}
}

func f<T>() -> (NonlexicalBox<T>) {}

////////////////////////////////////////////////////////////////////////////////
// Test }}
////////////////////////////////////////////////////////////////////////////////
Expand Down