99{-# LANGUAGE TupleSections #-}
1010{-# LANGUAGE TypeApplications #-}
1111
12- {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
12+
1313
1414module Nix.Eval where
1515
@@ -262,21 +262,23 @@ evalBinds recursive binds = do
262262 (M. toList o')
263263
264264 go _ (NamedVar pathExpr finalValue pos) = do
265- let go :: NAttrPath (m v ) -> m ([Text ], SourcePos , m v )
266- go = \ case
267- h :| t -> evalSetterKeyName h >>= \ case
268- Nothing ->
269- pure
270- ( mempty
271- , nullPos
272- , toValue @ (AttrSet v , AttrSet SourcePos ) (mempty , mempty )
273- )
274- Just k -> case t of
275- [] -> pure ([k], pos, finalValue)
276- x : xs -> do
277- (restOfPath, _, v) <- go (x :| xs)
278- pure (k : restOfPath, pos, v)
279- go pathExpr <&> \ case
265+ let
266+ gogo :: NAttrPath (m v ) -> m ([Text ], SourcePos , m v )
267+ gogo = \ case
268+ h :| t -> evalSetterKeyName h >>= \ case
269+ Nothing ->
270+ pure
271+ ( mempty
272+ , nullPos
273+ , toValue @ (AttrSet v , AttrSet SourcePos ) (mempty , mempty )
274+ )
275+ Just k -> case t of
276+ [] -> pure ([k], pos, finalValue)
277+ x : xs -> do
278+ (restOfPath, _, v) <- gogo (x :| xs)
279+ pure (k : restOfPath, pos, v)
280+
281+ gogo pathExpr <&> \ case
280282 -- When there are no path segments, e.g. `${null} = 5;`, we don't
281283 -- bind anything
282284 ([] , _, _) -> mempty
@@ -292,8 +294,8 @@ evalBinds recursive binds = do
292294 mv <- case ms of
293295 Nothing -> withScopes scope $ lookupVar key
294296 Just s ->
295- s >>= fromValue @ (AttrSet v , AttrSet SourcePos ) >>= \ (s , _) ->
296- clearScopes @ v $ pushScope s $ lookupVar key
297+ s >>= fromValue @ (AttrSet v , AttrSet SourcePos ) >>= \ (attrset , _) ->
298+ clearScopes @ v $ pushScope attrset $ lookupVar key
297299 case mv of
298300 Nothing -> attrMissing (key :| [] ) Nothing
299301 Just v -> demand v pure
0 commit comments