ndmitchell/hlint

fix -Wx-partial in Hint.Lambda and Hint.Extensions

shayne-fletcher opened this issue · 2 comments

happened to notice these -Wx-partial warnings in Hint.Lambda and Hint.Extensions. this was on the ghc-next branch. don't know if it's also on master.

[43 of 62] Compiling Hint.Lambda      ( src/Hint/Lambda.hs, /home/runner/tmp/ghc-lib/0.20240201/ghc-9.8.1/dist-newstyle/build/x86_64-linux/ghc-9.8.1/hlint-0.20240201/build/Hint/Lambda.o, /home/runner/tmp/ghc-lib/0.20240201/ghc-9.8.1/dist-newstyle/build/x86_64-linux/ghc-9.8.1/hlint-0.20240201/build/Hint/Lambda.dyn_o )
    |
133 |       L _ (LastStmt _ body b s) = head revs -- In a ListComp, this is always last.
    |                                   ^^^^
[44 of 62] Compiling Hint.Import      ( src/Hint/Import.hs, /home/runner/tmp/ghc-lib/0.20240201/ghc-9.8.1/dist-newstyle/build/x86_64-linux/ghc-9.8.1/hlint-0.20240201/build/Hint/Import.o, /home/runner/tmp/ghc-lib/0.20240201/ghc-9.8.1/dist-newstyle/build/x86_64-linux/ghc-9.8.1/hlint-0.20240201/build/Hint/Import.dyn_o )
src/Hint/List.hs:135:54: warning: [GHC-63394] [-Wx-partial]
[45 of 62] Compiling Hint.Fixities    ( src/Hint/Fixities.hs, /home/runner/tmp/ghc-lib/0.20240201/ghc-9.8.1/dist-newstyle/build/x86_64-linux/ghc-9.8.1/hlint-0.20240201/build/Hint/Fixities.o, /home/runner/tmp/ghc-lib/0.20240201/ghc-9.8.1/dist-newstyle/build/x86_64-linux/ghc-9.8.1/hlint-0.20240201/build/Hint/Fixities.dyn_o )
    In the use of ‘tail’
[46 of 62] Compiling Hint.Extensions  ( src/Hint/Extensions.hs, /home/runner/tmp/ghc-lib/0.20240201/ghc-9.8.1/dist-newstyle/build/x86_64-linux/ghc-9.8.1/hlint-0.20240201/build/Hint/Extensions.o, /home/runner/tmp/ghc-lib/0.20240201/ghc-9.8.1/dist-newstyle/build/x86_64-linux/ghc-9.8.1/hlint-0.20240201/build/Hint/Extensions.dyn_o )
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
    |
135 |       o2 =noLocA $ HsDo noAnn ctx (noLocA $ reverse (tail revs) ++ [last])
    |                                                      ^^^^

I fixed these all on master, so closing.

i think it's just the one warning: line 135 hint/List.hs. patching ghc-next to fix it up.