Skip to content

Replace use of tail with drop 1 in PlutusTx/Enum/TH.hs#7553

Merged
zeme-wana merged 1 commit intomasterfrom
fix-tail-use
Jan 30, 2026
Merged

Replace use of tail with drop 1 in PlutusTx/Enum/TH.hs#7553
zeme-wana merged 1 commit intomasterfrom
fix-tail-use

Conversation

@zeme-wana
Copy link
Collaborator

Fixes this error:

src/PlutusTx/Enum/TH.hs:53:59: error: [GHC-63394] [-Wx-partial, -Werror=x-partial]
    In the use of ‘tail’
    (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."
   |
53 |       [ funD 'succ (fmap (deriveSuccPred Succ) (zip cons (tail (Just <$> cons) ++ [Nothing])))
   |     

@zeme-wana zeme-wana added the No Changelog Required Add this to skip the Changelog Check label Jan 30, 2026
@zeme-wana zeme-wana merged commit d9268b1 into master Jan 30, 2026
47 of 49 checks passed
@zeme-wana zeme-wana deleted the fix-tail-use branch January 30, 2026 11:59
@kwxm
Copy link
Contributor

kwxm commented Jan 30, 2026

Is there any danger that this will actually get an empty list, or is the input guaranteed to be non-empty -in this situation? drop 1 [] is [], which might not be what we want. Matching on the list and failing for the empty list (which may be impossible) might be safer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No Changelog Required Add this to skip the Changelog Check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants