-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
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.
Description
| Previous ID | SR-15516 |
| Radar | None |
| Original Reporter | 0xF (JIRA User) |
| Type | Bug |
Environment
swiftc --version
compnerd.org Swift version 5.5.1 (swift-5.5.1-RELEASE)
Target: x86_64-unknown-windows-msvc
Additional Detail from JIRA
| Votes | 0 |
| Component/s | |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: 5a1c67b4ede674847b863256b69c4264
Issue Description:
This code fails to compile:
func plotSpcPattern(x : Int, y : Int, pattern : Int) -> UInt8
{
return UInt8(pattern >> ((~y & 1) * 8 + (~x & 3) * 2) & 3)
}The compiler outputs after about a minute:
swiftc -c -no-color-diagnostics reasonable.swift
reasonable.swift:3:9: error: the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
return UInt8(pattern >> ((~y & 1) * 8 + (~x & 3) * 2) & 3)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Exit code: 1
What is here to type-check? The function performs a bitwise AND with the literal 3, hence it returns values between 0 and 3.
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.