Skip to content

Commit 2781285

Browse files
committed
Sema: Extend DisjunctionStep::shouldSkip() hack to cover ~ & | ^ << >>
1 parent d1f34dc commit 2781285

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

lib/Sema/CSStep.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,9 @@ bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
737737
auto *declA = LastSolvedChoice->first->getOverloadChoice().getDecl();
738738
auto *declB = static_cast<Constraint *>(choice)->getOverloadChoice().getDecl();
739739

740-
if (declA->getBaseIdentifier().isArithmeticOperator() &&
740+
if ((declA->getBaseIdentifier().isArithmeticOperator() ||
741+
declA->getBaseIdentifier().isBitwiseOperator() ||
742+
declA->getBaseIdentifier().isShiftOperator()) &&
741743
TypeChecker::isDeclRefinementOf(declA, declB)) {
742744
return skip("subtype");
743745
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %target-swift-frontend -typecheck %s -solver-scope-threshold=80000
2+
3+
// REQUIRES: tools-release,no_asan
4+
5+
func f2() { let _ = 0 << (~(~(~(~(~(~(~(~(~(~(~(0 << 0)))))))))))) }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %target-swift-frontend -typecheck %s -solver-scope-threshold=2000
2+
3+
func f896() { let _ = ((0 >> ((0 >> 0) + ((0 / 0) & 0))) >> (0 << ((0 << 0) >> (0 << (0 << 0))))) }
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %target-swift-frontend -typecheck %s -solver-scope-threshold=15000
2+
3+
// REQUIRES: tools-release,no_asan
4+
5+
// Reduced from https://github.com/leif-ibsen/SwiftHPKE
6+
7+
struct Field25519 {
8+
static let mask51 = UInt64(0x7ffffffffffff)
9+
10+
var l0: UInt64
11+
var l1: UInt64
12+
var l2: UInt64
13+
var l3: UInt64
14+
var l4: UInt64
15+
16+
init(_ b: [UInt8]) {
17+
self.l0 = UInt64(b[0]) | UInt64(b[1]) << 8 | UInt64(b[2]) << 16 | UInt64(b[3]) << 24 | UInt64(b[4]) << 32 | UInt64(b[5]) << 40 | UInt64(b[6]) << 48 | UInt64(b[7]) << 56
18+
self.l1 = UInt64(b[6]) | UInt64(b[7]) << 8 | UInt64(b[8]) << 16 | UInt64(b[9]) << 24 | UInt64(b[10]) << 32 | UInt64(b[11]) << 40 | UInt64(b[12]) << 48 | UInt64(b[13]) << 56
19+
self.l2 = UInt64(b[12]) | UInt64(b[13]) << 8 | UInt64(b[14]) << 16 | UInt64(b[15]) << 24 | UInt64(b[16]) << 32 | UInt64(b[17]) << 40 | UInt64(b[18]) << 48 | UInt64(b[19]) << 56
20+
self.l3 = UInt64(b[19]) | UInt64(b[20]) << 8 | UInt64(b[21]) << 16 | UInt64(b[22]) << 24 | UInt64(b[23]) << 32 | UInt64(b[24]) << 40 | UInt64(b[25]) << 48 | UInt64(b[26]) << 56
21+
self.l4 = UInt64(b[24]) | UInt64(b[25]) << 8 | UInt64(b[26]) << 16 | UInt64(b[27]) << 24 | UInt64(b[28]) << 32 | UInt64(b[29]) << 40 | UInt64(b[30]) << 48 | UInt64(b[31]) << 56
22+
}
23+
}

0 commit comments

Comments
 (0)