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-7070] Compilation never seems to finish for literal array expression #49618

Open
swift-ci opened this issue Feb 24, 2018 · 1 comment
Open
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself performance type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-7070
Radar None
Original Reporter tcurdt (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Performance, TypeChecker
Assignee @xedin
Priority Medium

md5: 2621381c1646c125860053a4e992db17

Issue Description:

I've come across what I believe is a bug. I have code along the lines of:

func bar() -> [UInt8] {
 return [ 0x00 ]
 }
let foo: [UInt8] =
 bar() +
 bar() +
 ...
 bar()

Given that the types are very explicit I didn't think it should be too hard to figure out the type information. Yet if this list becomes longer compilation never finishes - at least not a reasonable time. I always aborted. Also because the CPU and memory usage was crazy. (40GB of RAM and counting).

Another similar example should also demonstrate the problem:

While this compiles fine

let foo: [UInt8] =
 [1] +
 [2]

this does not

let foo: [UInt8] =
 [1] +
 [2] +
 [3] +
 [4] +
 [5] +
 [6] +
 [7]

For the time being switching to

var foo: [UInt8] = []
 foo += bar()
 foo += bar()
 foo += bar()
 foo += bar()
 foo += bar()

is a really ugly workaround. If anyone has a better workaround please let me know.

I am using

$ swift -v
Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)
Target: x86_64-apple-macosx10.9
/Applications/Xcode.app/Contents/Developer/usr/bin/lldb "--repl=-enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -color-diagnostics"

@belkadan
Copy link
Contributor

cc @xedin

@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 performance type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants