From 08a6b0a2d69909a65594e9f8fa567af10fe991f7 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Mon, 16 Apr 2018 17:39:34 +1000 Subject: [PATCH] appease hlint --- src/Language/Ruby/Assignment.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index 54731081e..5b5426de1 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -177,9 +177,7 @@ identifier = where mk s = makeTerm <$> symbol s <*> (Syntax.Identifier . name <$> source) vcallOrLocal = do - loc <- symbol Identifier <|> symbol Identifier' - locals <- getRubyLocals - ident <- source + (loc, ident, locals) <- identWithLocals let identTerm = makeTerm loc (Syntax.Identifier (name ident)) if ident `elem` locals then pure identTerm @@ -410,11 +408,17 @@ assignment' = makeTerm <$> symbol Assignment <*> children (Statement.As <|> lhsIdent <|> expression -lhsIdent :: Assignment -lhsIdent = do +identWithLocals :: Assignment' (Record Location, ByteString, [ByteString]) +identWithLocals = do loc <- symbol Identifier <|> symbol Identifier' + -- source advances, so it's important we call getRubyLocals first locals <- getRubyLocals ident <- source + pure (loc, ident, locals) + +lhsIdent :: Assignment +lhsIdent = do + (loc, ident, locals) <- identWithLocals putRubyLocals (ident : locals) pure $ makeTerm loc (Syntax.Identifier (name ident))