Skip to content

Commit

Permalink
Merge branch 'main' into feature/combustion-delay
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 31, 2024
2 parents a179756 + 4c8477d commit 422e7b7
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def put = \y. place (y : Text); end;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def put = \y. [x = 3, z = 7]; end;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def put = \y. [x = 3, y]; end;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def put = \y. [x = 3, z = y + 2]; end;
22 changes: 21 additions & 1 deletion src/swarm-lang/Swarm/Language/LSP/VarUsage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,24 @@ getUsage bindings (CSyntax _pos t _comments) = case t of
Just v -> checkOccurrences bindings v Bind [s1, s2]
Nothing -> getUsage bindings s1 <> getUsage bindings s2
SDelay s -> getUsage bindings s
_ -> mempty
SRcd m -> M.foldMapWithKey (\x -> maybe (getUsage bindings (STerm (TVar x))) (getUsage bindings)) m
SProj s _ -> getUsage bindings s
SAnnotate s _ -> getUsage bindings s
SSuspend s -> getUsage bindings s
-- Explicitly enumerate the cases with no variables, instead of a
-- catch-all, so that we get a warning when adding new constructors.
TUnit {} -> mempty
TConst {} -> mempty
TDir {} -> mempty
TInt {} -> mempty
TAntiInt {} -> mempty
TText {} -> mempty
TAntiText {} -> mempty
TBool {} -> mempty
TRobot {} -> mempty
TRef {} -> mempty
TRequireDevice {} -> mempty
TRequire {} -> mempty
SRequirements {} -> mempty
STydef {} -> mempty
TType {} -> mempty
16 changes: 16 additions & 0 deletions test/unit/TestLSP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ testLSP =
checkFile
"single-bind-used.sw"
[]
, testCase "lambda with var used inside annotation" $
checkFile
"lambda-with-annot.sw"
[]
, testCase "record with used var" $
checkFile
"lambda-with-record-used.sw"
[]
, testCase "record with used var abbrev" $
checkFile
"lambda-with-record-used-abbrev.sw"
[]
, testCase "record with unused var" $
checkFile
"lambda-with-record-unused.sw"
[UnusedVar "y" VU.Lambda]
]
where
checkFile :: FilePath -> [UnusedVar] -> IO ()
Expand Down

0 comments on commit 422e7b7

Please sign in to comment.