Skip to content
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

Type parameter pack crash while attempting to create resultBuilder with variadic tuple element #76517

Open
LuizZak opened this issue Sep 17, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels

Comments

@LuizZak
Copy link
Contributor

LuizZak commented Sep 17, 2024

Description

No response

Reproduction

protocol Element {
}

struct TupleElement<each T: Element>: Element {
    var t: (repeat each T)
}

@resultBuilder
struct ElementBuilder {
    static func buildBlock<each T: Element>(_ value: repeat each T) -> TupleElement<repeat each T> {
        return TupleElement(t: repeat each value)
    }
}

Stack dump

Stack dump:
0.      Program arguments: /home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend -frontend -interpret tuple-pack-bonanza.swift -disable-objc-interop -color-diagnostics -empty-abi-descriptor -resource-dir /home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/lib/swift -module-name main -plugin-path /home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/lib/swift/host/plugins -plugin-path /home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/local/lib/swift/host/plugins
1.      Swift version 6.0 (swift-6.0-RELEASE)
2.      Compiling with effective version 5.10
3.      While evaluating request TypeCheckSourceFileRequest(source_file "tuple-pack-bonanza.swift")
4.      While evaluating request TypeCheckFunctionBodyRequest(main.(file)[email protected]:10:17)
5.      While type-checking statement at [tuple-pack-bonanza.swift:10:100 - line:12:5] RangeText="{
        return TupleElement(t: repeat each value)
    "
6.      While type-checking statement at [tuple-pack-bonanza.swift:11:9 - line:11:49] RangeText="return TupleElement(t: repeat each value"
7.      While type-checking-target starting at tuple-pack-bonanza.swift:11:16
 #0 0x000055d221d7c377 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x7360377)
 #1 0x000055d221d7a30e llvm::sys::RunSignalHandlers() (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x735e30e)
 #2 0x000055d221d7c9ef SignalHandler(int) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x73609ef)
 #3 0x00007f899d325420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x000055d21d187a94 (anonymous namespace)::ExprRewriter::coerceToType(swift::Expr*, swift::Type, swift::constraints::ConstraintLocatorBuilder) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x276ba94)
 #5 0x000055d21d19efd2 (anonymous namespace)::ExprRewriter::coerceCallArguments(swift::ArgumentList*, swift::AnyFunctionType*, swift::ConcreteDeclRef, swift::ApplyExpr*, swift::constraints::ConstraintLocatorBuilder, llvm::ArrayRef<swift::AppliedPropertyWrapper>) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2782fd2)
 #6 0x000055d21d1a769e (anonymous namespace)::ExprRewriter::finishApply(swift::ApplyExpr*, swift::Type, swift::constraints::ConstraintLocatorBuilder, swift::constraints::ConstraintLocatorBuilder) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x278b69e)
 #7 0x000055d21d1a846f (anonymous namespace)::ExprRewriter::finishApply(swift::ApplyExpr*, swift::Type, swift::constraints::ConstraintLocatorBuilder, swift::constraints::ConstraintLocatorBuilder) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x278c46f)
 #8 0x000055d21d1ada24 (anonymous namespace)::ExprRewriter::visitApplyExpr(swift::ApplyExpr*) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2791a24)
 #9 0x000055d21d18ec32 (anonymous namespace)::ExprRewriter::walkToExprPost(swift::Expr*) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2772c32)
#10 0x000055d21d18bf70 (anonymous namespace)::ExprWalker::walkToExprPost(swift::Expr*) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x276ff70)
#11 0x000055d21d86289b swift::Expr::walk(swift::ASTWalker&) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2e4689b)
#12 0x000055d21d18481d (anonymous namespace)::ExprWalker::rewriteTarget(swift::constraints::SyntacticElementTarget) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x276881d)
#13 0x000055d21d1842d2 swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::constraints::SyntacticElementTarget) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x27682d2)
#14 0x000055d21d3adb26 swift::TypeChecker::typeCheckTarget(swift::constraints::SyntacticElementTarget&, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2991b26)
#15 0x000055d21d4e318e swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2ac718e)
#16 0x000055d21d4e1ddc bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2ac5ddc)
#17 0x000055d21d4de654 (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2ac2654)
#18 0x000055d21d4e1f1c swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2ac5f1c)
#19 0x000055d21d4e052c bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2ac452c)
#20 0x000055d21d4dfbe3 (anonymous namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2ac3be3)
#21 0x000055d21d4df8c4 swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2ac38c4)
#22 0x000055d21d956a77 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'()) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2f3aa77)
#23 0x000055d21d8d1413 swift::AbstractFunctionDecl::getTypecheckedBody() const (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2eb5413)
#24 0x000055d21d9f6329 swift::SourceFile::typeCheckDelayedFunctions() (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2fda329)
#25 0x000055d21d523f98 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2b07f98)
#26 0x000055d21d5260dd 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'()) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2b0a0dd)
#27 0x000055d21d523e95 swift::performTypeChecking(swift::SourceFile&) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x2b07e95)
#28 0x000055d21c36698c swift::CompilerInstance::performSema() (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x194a98c)
#29 0x000055d21c0de05f withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x16c205f)
#30 0x000055d21c0d39ea performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x16b79ea)
#31 0x000055d21c0d1bff swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x16b5bff)
#32 0x000055d21bea84fd swift::mainEntry(int, char const**) (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x148c4fd)
#33 0x00007f899b781083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#34 0x000055d21bea6cae _start (/home/luiz/.local/share/swiftly/toolchains/6.0.0/usr/bin/swift-frontend+0x148acae)

💣 Program crashed: Bad pointer dereference at 0x0000000000000018

Thread 0 "swift-frontend" crashed:

0 0x000055d21d187a94 (anonymous namespace)::ExprRewriter::coerceToType(swift::Expr*, swift::Type, swift::constraints::ConstraintLocatorBuilder) + 3972 in swift-frontend

Expected behavior

Expected either to compile successfully or raise a semantic error of some sort.

Environment

Swift version 6.0 (swift-6.0-RELEASE)
Target: x86_64-unknown-linux-gnu

Additional information

No response

@LuizZak LuizZak added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant