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

[SR-13253] Compiler hangs building invalid code #55693

Open
swift-ci opened this issue Jul 19, 2020 · 2 comments
Open

[SR-13253] Compiler hangs building invalid code #55693

swift-ci opened this issue Jul 19, 2020 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-13253
Radar https://feedbackassistant.apple.com/feedback/8066568
Original Reporter dmehers (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode Version 12.0 beta 2 (12A6163b)

Apple Swift version 5.3 (swiftlang-1200.0.16.13 clang-1200.0.22.25)

Target: x86_64-apple-darwin19.6.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 58be4b51ed610315d0ccc118ec7f11f6

Issue Description:

I'm getting a hang compiling the attached invalid code:

/Applications/Xcode_12_beta_2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift /Users/damian/Downloads/test/test/ContentView.swift
/Users/damian/Downloads/test/test/ContentView.swift:9:25: error: cannot find 'totalseconds' in scope
let hours = totalseconds / 3600
^~~~~~~~~~~~
/Users/damian/Downloads/test/test/ContentView.swift:10:29: error: cannot find 'totalseconds' in scope
let remaining = totalseconds % 3600
^~~~~~~~~~~~

...hangs

import SwiftUI

struct TimeElapsedView: View {
    let interval : DateInterval
    
    var body : some View {
        HStack {
            let totalSeconds = Int(interval.duration)
            let hours = totalseconds / 3600
            let remaining = totalseconds % 3600
            let minutes = remaining / 60
            let seconds = remaining % 60

        }
    }
}

struct TimeElapsedView_Previews: PreviewProvider {
    static var previews: some View {
        TimeElapsedView()
    }
}
@theblixguy
Copy link
Collaborator

On master, the compiler doesn't hang for me and produces the following diagnostics:

/Users/spare/Desktop/test.swift:9:25: error: cannot find 'totalseconds' in scope
            let hours = totalseconds / 3600
                        ^~~~~~~~~~~~
/Users/spare/Desktop/test.swift:10:29: error: cannot find 'totalseconds' in scope
            let remaining = totalseconds % 3600
                            ^~~~~~~~~~~~
/Users/spare/Desktop/test.swift:7:9: error: type of expression is ambiguous without more context
        HStack {
        ^~~~~~~~
/Users/spare/Desktop/test.swift:20:25: error: missing argument for parameter 'interval' in call
        TimeElapsedView()
                        ^
                        interval: <#DateInterval#>
/Users/spare/Desktop/test.swift:3:8: note: 'init(interval:)' declared here
struct TimeElapsedView: View {
       ^

Could you verify using the latest trunk snapshot from swift.org?

@swift-ci
Copy link
Collaborator Author

Comment by Damian Mehers (JIRA)

Looks better with 16 Jul dev snapshot:

damian@Damians-iMac-Pro-3 ~ % swift --version
Apple Swift version 5.3 (swiftlang-1200.0.16.13 clang-1200.0.22.25)
Target: x86_64-apple-darwin19.6.0
damian@Damians-iMac-Pro-3 ~ % swift /Users/damian/Downloads/test/test/ContentView.swift
/Users/damian/Downloads/test/test/ContentView.swift:9:25: error: cannot find 'totalseconds' in scope
            let hours = totalseconds / 3600
                        ^~~~~~~~~~~~
/Users/damian/Downloads/test/test/ContentView.swift:10:29: error: cannot find 'totalseconds' in scope
            let remaining = totalseconds % 3600
                            ^~~~~~~~~~~~
// HANGING

^C
damian@Damians-iMac-Pro-3 ~ % export PATH=/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-07-16-a.xctoolchain/usr/bin::"${PATH}"
damian@Damians-iMac-Pro-3 ~ % swift --version                                                                                                 
Apple Swift version 5.3-dev (LLVM a2e0564af78e841, Swift 1224d8b2d312c55)
Target: x86_64-apple-darwin19.6.0
damian@Damians-iMac-Pro-3 ~ % swift /Users/damian/Downloads/test/test/ContentView.swift                                                       
/Users/damian/Downloads/test/test/ContentView.swift:9:25: error: cannot find 'totalseconds' in scope
            let hours = totalseconds / 3600
                        ^~~~~~~~~~~~
/Users/damian/Downloads/test/test/ContentView.swift:10:29: error: cannot find 'totalseconds' in scope
            let remaining = totalseconds % 3600
                            ^~~~~~~~~~~~
/Users/damian/Downloads/test/test/ContentView.swift:7:9: error: type of expression is ambiguous without more context
        HStack {
        ^~~~~~~~
/Users/damian/Downloads/test/test/ContentView.swift:20:25: error: missing argument for parameter 'interval' in call
        TimeElapsedView()
                        ^
                        interval: <#DateInterval#>
/Users/damian/Downloads/test/test/ContentView.swift:3:8: note: 'init(interval:)' declared here
struct TimeElapsedView: View {
       ^
damian@Damians-iMac-Pro-3 ~ % 

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants