-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.call expressionsFeature → expressions: Call expressionsFeature → expressions: Call expressionscompilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareexpressionsFeature: expressionsFeature: expressionsoverloadingFeature: Overloading symbol namesFeature: Overloading symbol namesregressionswift 5.10swift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
Description
The compiler crashes when type-checking the body of var computedValue: Int
, crash is avoided when public static func closure(from:)
is renamed to not collide with stored property closure.
Reproduction
public struct Foo {
public let closure: (Int) -> ((Int) -> Int)
public var computedValue: Int {
return closure(0)(1)
}
public static func closure(from: String) -> (Int) -> ((Int) -> Int) {
return { _ in
return { _ in
return 0
}
}
}
}
Stack dump
1.Facebook Swift version 6.0-dev (LLVM 169e770b9a04512, Swift bee4c03979a4f3b)
2.Compiling with effective version 5.10
3.While evaluating request TypeCheckSourceFileRequest(source_file "Module/Example.swift")
4.While evaluating request TypeCheckFunctionBodyRequest(Module.(file).Foo._@Module/Example.swift:8:33)
5.While type-checking statement at [Module/Example.swift:8:33 - line:10:3] RangeText="{
return closure(0)(1)
"
6.While type-checking statement at [Module/Example.swift:9:5 - line:9:24] RangeText="return closure(0)(1"
7.While type-checking-target starting at Module/Example.swift:9:12
#0 0x0000555b7aa9cb48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /path/to/llvm-project/llvm/lib/Support/Unix/Signals.inc:616:8
#1 0x0000555b7aa9d4bb RunSignalHandlers /path/to/llvm-project/llvm/lib/Support/Signals.cpp:105:18
#2 0x0000555b7aa9d4bb SignalHandler(int) /path/to/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:3
#3 0x00007f1517444560 __restore_rt (/path/to/cplatform/lib/libc.so.6+0x44560)
#4 0x00007f151749c993 pthread_kill@@GLIBC_2.34 (/path/to/cplatform/lib/libc.so.6+0x9c993)
#5 0x00007f15174444ad gsignal (/path/to/cplatform/lib/libc.so.6+0x444ad)
#6 0x00007f151742c433 abort (/path/to/cplatform/lib/libc.so.6+0x2c433)
#7 0x00007f151743bc28 __assert_fail_base (/path/to/cplatform/lib/libc.so.6+0x3bc28)
#8 0x00007f151743bc93 (/path/to/cplatform/lib/libc.so.6+0x3bc93)
#9 0x0000555b7629df54 operator() /path/to/swift/lib/Sema/ConstraintSystem.cpp:694:35
#10 0x0000555b7629df54 swift::constraints::ConstraintSystem::getCalleeLocator(swift::constraints::ConstraintLocator*, bool, llvm::function_ref<swift::Type (swift::Expr*)>, llvm::function_ref<swift::Type (swift::Type)>, llvm::function_ref<std::optional<swift::constraints::SelectedOverload> (swift::constraints::ConstraintLocator*)>) /path/to/swift/lib/Sema/ConstraintSystem.cpp:711:23
#11 0x0000555b761bcc92 getCalleeLocator /path/to/swift/include/swift/Sema/ConstraintSystem.h:0:12
#12 0x0000555b761bcc92 matchFunctionResultTypes /path/to/swift/lib/Sema/CSSimplify.cpp:2088:13
#13 0x0000555b761bcc92 swift::constraints::ConstraintSystem::simplifyApplicableFnConstraint(swift::Type, swift::Type, std::optional<swift::constraints::TrailingClosureMatching>, swift::optionset::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) /path/to/swift/lib/Sema/CSSimplify.cpp:13309:9
#14 0x0000555b7619063d addConstraintImpl /path/to/swift/lib/Sema/CSSimplify.cpp:0:12
#15 0x0000555b7619063d swift::constraints::ConstraintSystem::addConstraint(swift::constraints::ConstraintKind, swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder, bool) /path/to/swift/lib/Sema/CSSimplify.cpp:15781:11
#16 0x0000555b7612c7de (anonymous namespace)::ConstraintGenerator::visitApplyExpr(swift::ApplyExpr*) /path/to/swift/lib/Sema/CSGen.cpp:3323:11
#17 0x0000555b7611c721 visit /path/to/swift/include/swift/AST/Expr.h:0:56
#18 0x0000555b7611c721 (anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*) /path/to/swift/lib/Sema/CSGen.cpp:4397:26
#19 0x0000555b767431f0 traverse<swift::Expr> /path/to/swift/lib/AST/ASTWalker.cpp:1513:25
#20 0x0000555b767431f0 (anonymous namespace)::Traversal::doIt(swift::Expr*) /path/to/swift/lib/AST/ASTWalker.cpp:1543:12
#21 0x0000555b76743113 swift::Expr::walk(swift::ASTWalker&) /path/to/swift/lib/AST/ASTWalker.cpp:2397:3
#22 0x0000555b761146d1 generateConstraintsFor /path/to/swift/lib/Sema/CSGen.cpp:4425:7
#23 0x0000555b761146d1 generateConstraints /path/to/swift/lib/Sema/CSGen.cpp:5011:10
#24 0x0000555b761146d1 swift::constraints::ConstraintSystem::generateConstraints(swift::constraints::SyntacticElementTarget&, swift::FreeTypeVariableBinding) /path/to/swift/lib/Sema/CSGen.cpp:4830:12
#25 0x0000555b761f3755 swift::constraints::ConstraintSystem::solveImpl(swift::constraints::SyntacticElementTarget&, swift::FreeTypeVariableBinding) /path/to/swift/lib/Sema/CSSolver.cpp:1609:7
#26 0x0000555b761f30df getKind /path/to/swift/include/swift/Sema/SolutionResult.h:113:32
#27 0x0000555b761f30df swift::constraints::ConstraintSystem::solve(swift::constraints::SyntacticElementTarget&, swift::FreeTypeVariableBinding) /path/to/swift/lib/Sema/CSSolver.cpp:1517:22
#28 0x0000555b7637fe80 _M_is_engaged /mnt/gvfs/third-party2/libgcc/d1129753c8361ac8e9453c0f4291337a4507ebe6/11.x/platform010/5684a5a/include/c++/11.x/optional:434:58
#29 0x0000555b7637fe80 operator bool /mnt/gvfs/third-party2/libgcc/d1129753c8361ac8e9453c0f4291337a4507ebe6/11.x/platform010/5684a5a/include/c++/11.x/optional:938:22
#30 0x0000555b7637fe80 swift::TypeChecker::typeCheckTarget(swift::constraints::SyntacticElementTarget&, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>) /path/to/swift/lib/Sema/TypeCheckConstraints.cpp:527:8
#31 0x0000555b764b5bbf _M_is_engaged /mnt/gvfs/third-party2/libgcc/d1129753c8361ac8e9453c0f4291337a4507ebe6/11.x/platform010/5684a5a/include/c++/11.x/optional:434:58
#32 0x0000555b764b5bbf operator bool /mnt/gvfs/third-party2/libgcc/d1129753c8361ac8e9453c0f4291337a4507ebe6/11.x/platform010/5684a5a/include/c++/11.x/optional:938:22
#33 0x0000555b764b5bbf visitReturnStmt /path/to/swift/lib/Sema/TypeCheckStmt.cpp:1081:9
#34 0x0000555b764b5bbf swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) /path/to/swift/include/swift/AST/StmtNodes.def:48:1
#35 0x0000555b764b5a42 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) /path/to/swift/lib/Sema/TypeCheckStmt.cpp:1029:12
#36 0x0000555b764b2028 (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) /path/to/swift/lib/Sema/TypeCheckStmt.cpp:2091:12
#37 0x0000555b764b5aff visitBraceStmt /path/to/swift/lib/Sema/TypeCheckStmt.cpp:2130:19
#38 0x0000555b764b5aff swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) /path/to/swift/include/swift/AST/StmtNodes.def:47:1
#39 0x0000555b764b3e12 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) /path/to/swift/lib/Sema/TypeCheckStmt.cpp:1028:39
#40 0x0000555b764b317c typeCheckBody /path/to/swift/lib/Sema/TypeCheckStmt.cpp:0:21
#41 0x0000555b764b317c swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const /path/to/swift/lib/Sema/TypeCheckStmt.cpp:2948:19
#42 0x0000555b768447f6 swift::TypeCheckFunctionBodyRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType)::'lambda'()>(swift::TypeCheckFunctionBodyRequest const&, swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType)::'lambda'()) /path/to/swift/include/swift/AST/Evaluator.h:322:19
#43 0x0000555b767ccc9c getResultCached<swift::TypeCheckFunctionBodyRequest, (lambda at /path/to/swift/include/swift/AST/Evaluator.h:416:20), nullptr> /path/to/swift/include/swift/AST/Evaluator.h:351:19
#44 0x0000555b767ccc9c operator()<swift::TypeCheckFunctionBodyRequest, (lambda at /path/to/swift/include/swift/AST/Evaluator.h:416:20), nullptr> /path/to/swift/include/swift/AST/Evaluator.h:226:14
#45 0x0000555b767ccc9c evaluateOrDefault<swift::TypeCheckFunctionBodyRequest> /path/to/swift/include/swift/AST/Evaluator.h:416:10
#46 0x0000555b767ccc9c swift::AbstractFunctionDecl::getTypecheckedBody() const /path/to/swift/lib/AST/Decl.cpp:9471:10
#47 0x0000555b768e3c44 swift::SourceFile::typeCheckDelayedFunctions() /path/to/swift/lib/AST/Module.cpp:3561:24
#48 0x0000555b764efcce swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const /path/to/swift/lib/Sema/TypeChecker.cpp:0:9
#49 0x0000555b764f1b8f swift::TypeCheckSourceFileRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType)::'lambda'()>(swift::TypeCheckSourceFileRequest const&, swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType)::'lambda'()) /path/to/swift/include/swift/AST/Evaluator.h:324:14
#50 0x0000555b764efb59 getResultCached<swift::TypeCheckSourceFileRequest, (lambda at /path/to/swift/include/swift/AST/Evaluator.h:416:20), nullptr> /path/to/swift/include/swift/AST/Evaluator.h:354:13
#51 0x0000555b764efb59 operator()<swift::TypeCheckSourceFileRequest, (lambda at /path/to/swift/include/swift/AST/Evaluator.h:416:20), nullptr> /path/to/swift/include/swift/AST/Evaluator.h:226:14
#52 0x0000555b764efb59 evaluateOrDefault<swift::TypeCheckSourceFileRequest> /path/to/swift/include/swift/AST/Evaluator.h:416:10
#53 0x0000555b764efb59 swift::performTypeChecking(swift::SourceFile&) /path/to/swift/lib/Sema/TypeChecker.cpp:277:16
#54 0x0000555b75319af0 forEachFileToTypeCheck /path/to/swift/lib/Frontend/Frontend.cpp:1596:24
#55 0x0000555b75319af0 swift::CompilerInstance::performSema() /path/to/swift/lib/Frontend/Frontend.cpp:1526:3
#56 0x0000555b750d90de withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) /path/to/swift/lib/FrontendTool/FrontendTool.cpp:1139:7
#57 0x0000555b750cd19e performAction /path/to/swift/lib/FrontendTool/FrontendTool.cpp:0:0
#58 0x0000555b750cd19e performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) /path/to/swift/lib/FrontendTool/FrontendTool.cpp:1371:19
#59 0x0000555b750cc0e9 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) /path/to/swift/lib/FrontendTool/FrontendTool.cpp:2054:19
#60 0x0000555b7506a68b run_driver /path/to/swift/lib/DriverTool/driver.cpp:0:0
#61 0x0000555b7506a68b swift::mainEntry(int, char const**) /path/to/swift/lib/DriverTool/driver.cpp:531:10
#62 0x00007f151742c657 __libc_start_call_main (/path/to/cplatform/lib/libc.so.6+0x2c657)
#63 0x00007f151742c718 __libc_start_main@GLIBC_2.2.5 (/path/to/cplatform/lib/libc.so.6+0x2c718)
#64 0x0000555b74d737b1 _start /path/to/start.S:118:0
Expected behavior
Compiler should distinguish between stored property closure
and static func closure(from:)
Environment
Swift compiler 6.0 built from dc55303
Swift language version 5.10
Additional information
No response
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.call expressionsFeature → expressions: Call expressionsFeature → expressions: Call expressionscompilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareexpressionsFeature: expressionsFeature: expressionsoverloadingFeature: Overloading symbol namesFeature: Overloading symbol namesregressionswift 5.10swift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis