Skip to content

Commit

Permalink
Merge pull request swiftlang#11208 from CodaFi/paren-de-la-paren
Browse files Browse the repository at this point in the history
Report nested inout paren types as non-materializable
  • Loading branch information
CodaFi authored Jul 26, 2017
2 parents 2cda3e0 + 43beb80 commit d033648
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2704,7 +2704,16 @@ Type TupleType::get(ArrayRef<TupleTypeElt> Fields, const ASTContext &C) {
if (!eltTy) continue;

properties |= eltTy->getRecursiveProperties();
hasInOut |= Elt.getParameterFlags().isInOut();
// Recur into paren types and canonicalized paren types. 'inout' in nested
// non-paren tuples are malformed and will be diagnosed later.
if (auto *TTy = Elt.getType()->getAs<TupleType>()) {
if (TTy->getNumElements() == 1)
hasInOut |= TTy->hasInOutElement();
} else if (auto *Pty = dyn_cast<ParenType>(Elt.getType().getPointer())) {
hasInOut |= Pty->getParameterFlags().isInOut();
} else {
hasInOut |= Elt.getParameterFlags().isInOut();
}
}

auto arena = getArena(properties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

// REQUIRES: asserts
// RUN: not --crash %target-swift-frontend %s -emit-ir
// RUN: not %target-swift-frontend %s -emit-ir
[(Int
(t:&_

0 comments on commit d033648

Please sign in to comment.