File tree Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -765,18 +765,15 @@ getFreeVars e =
765765 (NHasAttr expr path) -> getFreeVars expr <> pathFree path
766766 (NAbs (Param varname) expr) -> Set. delete varname (getFreeVars expr)
767767 (NAbs (ParamSet varname _ pset) expr) ->
768- -- Include all free variables from the expression and the default arguments
769- getFreeVars expr <>
770- -- But remove the argument name if existing, and all arguments in the parameter set
771768 Set. difference
772- (Set. unions $ getFreeVars <$> mapMaybe snd pset)
773- (Set. difference
774- (one `whenJust` varname)
775- (Set. fromList $ fst <$> pset)
776- )
769+ -- Include all free variables from the expression and the default arguments
770+ (getFreeVars expr <> (Set. unions $ getFreeVars <$> mapMaybe snd pset))
771+ -- But remove the argument name if existing, and all arguments in the parameter set
772+ ((one `whenJust` varname) <> (Set. fromList $ fst <$> pset))
777773 (NLet bindings expr ) ->
778- getFreeVars expr <>
779- diffBetween bindFreeVars bindDefs bindings
774+ Set. difference
775+ (getFreeVars expr <> bindFreeVars bindings)
776+ (bindDefs bindings)
780777 (NIf cond th el ) -> Set. unions $ getFreeVars <$> [cond, th, el]
781778 -- Evaluation is needed to find out whether x is a "real" free variable in `with y; x`, we just include it
782779 -- This also makes sense because its value can be overridden by `x: with y; x`
Original file line number Diff line number Diff line change @@ -455,6 +455,18 @@ case_regression_373 =
455455 )
456456 ]
457457
458+ case_bound_vars :: Assertion
459+ case_bound_vars =
460+ traverse_ noFreeVars
461+ [ " a: a"
462+ , " {b}: b"
463+ , " let c = 5; d = c; in d"
464+ , " rec { e = 5; f = e; }"
465+ ]
466+ where
467+ noFreeVars = flip sameFreeVars mempty
468+
469+
458470case_expression_split =
459471 constantEqualText
460472 " [ \"\" [ \" a\" ] \" c\" ]"
You can’t perform that action at this time.
0 commit comments