Skip to content

[TF-194] [TF-195] cherry-pick some autocomplete crasher fixes into tensorflow #22589

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 2 commits into from
Feb 13, 2019
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
4 changes: 4 additions & 0 deletions lib/Sema/TypeCheckREPL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ void REPLChecker::generatePrintOfExpression(StringRef NameStr, Expr *E) {
/// When we see an expression in a TopLevelCodeDecl in the REPL, process it,
/// adding the proper decls back to the top level of the file.
void REPLChecker::processREPLTopLevelExpr(Expr *E) {
// Don't try to print expressions without types.
if (!E->getType())
return;

CanType T = E->getType()->getCanonicalType();

// Don't try to print invalid expressions, module exprs, or void expressions.
Expand Down
3 changes: 2 additions & 1 deletion lib/Sema/TypeCheckStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
Type contextType = yieldType;
if (yieldResults[i].isInOut()) {
contextTypePurpose = CTP_YieldByReference;
contextType = LValueType::get(contextType);
if (!contextType->hasError())
contextType = LValueType::get(contextType);

// Check that the yielded expression is a &.
if ((inout = dyn_cast<InOutExpr>(exprToCheck))) {
Expand Down
7 changes: 7 additions & 0 deletions test/IDE/complete_tf_194.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// https://bugs.swift.org/browse/TF-194: invalid unary ops crash repl completer

// The ASTVerifier doesn't like this AST.
// XFAIL: swift_ast_verifier

// RUN: %target-swift-ide-test -repl-code-completion -source-filename=%s
%invalidunary le
8 changes: 8 additions & 0 deletions test/IDE/complete_tf_195.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// https://bugs.swift.org/browse/TF-195: repl completer crash while defining
// struct

// The ASTVerifier doesn't like this AST.
// XFAIL: swift_ast_verifier

// RUN: %target-swift-ide-test -repl-code-completion -source-filename=%s
struct Foo { var ba