-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Closed
Copy link
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.compilerThe Swift compiler itselfThe Swift compiler itselftype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
| Previous ID | SR-11610 |
| Radar | rdar://problem/56630529 |
| Original Reporter | kuwerty (JIRA User) |
| Type | Bug |
Attachment: Download
Environment
Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7)
Target: x86_64-apple-darwin19.0.0
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, TypeChecker |
| Assignee | None |
| Priority | Medium |
md5: 2212158c4b3316b9b643e2f66d2d5f8f
Issue Description:
$ swift -O foo.swift
foo.swift:21:21: error: the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
return p0*mt*mt + (p1 * (2.0*mt) + p2 * t)foo.swift
typealias vec2 = SIMD2<Float>
struct Quadratic {
let p0 : vec2
let p1 : vec2
let p2 : vec2
init(_ p0:vec2, _ p1:vec2, _ p2:vec2) {
self.p0 = p0
self.p1 = p1
self.p2 = p2
}
func eval(_ t:Float) -> vec2 {
let mt : Float = 1.0 - t;
let mtmt : Float = mt * mt
// replace p0*mt*mt with p0mtmt and it succeeds but (subjectively) takes
// a long time to compile 25 lines of code. 2s vs 0.2s when returning a literal
//let p0mtmt : vec2 = p0 * mtmt
return p0*mt*mt + (p1 * (2.0*mt) + p2 * t)
}
}
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.compilerThe Swift compiler itselfThe Swift compiler itselftype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis