Skip to content

Commit fd12423

Browse files
committed
[fix-all 2] Fix incorrect reordering for all
See test case
1 parent c064637 commit fd12423

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

glean/db/Glean/Query/Reorder.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,9 @@ toCgStatement stmt = case stmt of
929929
lhs' <- fixVars IsPat lhs
930930
return [CgStatement lhs' gen']
931931
FlatAllStatement v e g -> do
932-
cg <- withScopeFor (scopeVars g <> vars e) $ do
932+
-- withinNegation enforces that bindings within the all are local
933+
-- to this scope and not visible outside.
934+
cg <- withinNegation $ withScopeFor (scopeVars g <> vars e) $ do
933935
stmts <- reorderGroup g
934936
e' <- fixVars IsExpr e
935937
return [CgAllStatement v e' stmts]

glean/test/tests/Angle/SetTest.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import Glean.Typed.Binary
3636
import Glean.Types
3737

3838
import qualified Data.HashMap.Strict as HashMap
39-
import Data.Set
39+
import Data.Set as Set
4040

4141
import Test.HUnit
4242
import TestRunner
@@ -161,6 +161,11 @@ setSemanticsTest dbTestCase = TestList
161161
r <- runQuery_ env repo $ angleData @Nat
162162
[s| X where _ = all (X = 1); X = 0 |]
163163
assertEqual "unused all" r [Nat 0]
164+
, TestLabel "local constraint" $ dbTestCase $ \env repo -> do
165+
r <- runQuery_ env repo $ angleData @(Set Nat)
166+
[s| all (X where X = 1) where X = 1|2 |]
167+
assertEqual "local constraint"
168+
(sort r) [Set.empty, Set.fromList [Nat 1]]
164169
]
165170

166171
setLimitTest :: Test

0 commit comments

Comments
 (0)