Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 0c10686

Browse files
committed
Record where names were bound.
1 parent 09f2362 commit 0c10686

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

semantic-core/src/Analysis/ScopeGraph.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ runFile
5555
-> m (File (Either (Loc, String) ScopeGraph))
5656
runFile file = traverse run file
5757
where run = runReader (fileLoc file)
58+
. runReader (Map.empty @User @Loc)
5859
. runFailWithLoc
5960
. fmap fold
6061
. convergeTerm (fix (cacheTerm . eval scopeGraphAnalysis))
@@ -63,12 +64,16 @@ runFile file = traverse run file
6364
scopeGraphAnalysis
6465
:: ( Alternative m
6566
, Carrier sig m
67+
, Member (Reader Loc) sig
68+
, Member (Reader (Map.Map User Loc)) sig
6669
, Member (State (Heap User ScopeGraph)) sig
6770
)
6871
=> Analysis User ScopeGraph m
6972
scopeGraphAnalysis = Analysis{..}
7073
where alloc = pure
71-
bind _ _ m = m
74+
bind name _ m = do
75+
loc <- ask @Loc
76+
local (Map.insert name loc) m
7277
lookupEnv = pure . Just
7378
deref addr = gets (Map.lookup addr) >>= maybe (pure Nothing) (foldMapA (pure . Just)) . nonEmpty . maybe [] (Set.toList @ScopeGraph)
7479
assign addr ty = modify (Map.insertWith (<>) addr (Set.singleton ty))

0 commit comments

Comments
 (0)