Skip to content

Analyse top-level pattern bindings#93

Merged
ocharles merged 3 commits intoocharles:masterfrom
amesgen:top-level-patterns
Dec 8, 2021
Merged

Analyse top-level pattern bindings#93
ocharles merged 3 commits intoocharles:masterfrom
amesgen:top-level-patterns

Conversation

@amesgen
Copy link
Copy Markdown
Contributor

@amesgen amesgen commented Dec 1, 2021

Closes #92

With this patch, weeder correctly outputs

app/Dep.hs:7: b

for the example in #92, so both the false negative and false positive are fixed by this.


The binding

(a, b) = (xxx, 1)

has HIE AST

Node app/Dep.hs:7:1-17 [(AbsBinds, HsBindLR),
                        (PatBind, HsBindLR)] [] []
  Node app/Dep.hs:7:1-6 [(TuplePat, Pat)] [1] []
      Node app/Dep.hs:7:2 [(VarPat, Pat)] [0] [(Right a,
                                                IdentifierDetails Just 0 {PatternBind ModuleScope (LocalScope SrcSpanOneLine "app/Dep.hs" 7 5 6) (Just SrcSpanOneLine "app/Dep.hs" 7 1 18)})]
      Node app/Dep.hs:7:5 [(VarPat, Pat)] [0] [(Right b,
                                                IdentifierDetails Just 0 {PatternBind ModuleScope NoScope (Just SrcSpanOneLine "app/Dep.hs" 7 1 18)})]
  Node app/Dep.hs:7:8-17 [(GRHS, GRHS)] [] []
      Node app/Dep.hs:7:10-17 [(ExplicitTuple, HsExpr)] [] []
            Node app/Dep.hs:7:11-13 [(HsVar, HsExpr),
                                     (Present, HsTupArg)] [0] [(Right xxx,
                                                                IdentifierDetails Just 0 {Use})]
            Node app/Dep.hs:7:16 [(HsOverLit, HsExpr),
                                  (Present, HsTupArg)] [0] []

so I hope that PatBind is the correct thing to look out for in additon to FunBind.

@amesgen
Copy link
Copy Markdown
Contributor Author

amesgen commented Dec 1, 2021

I took the liberty to add a tiny commit which fixes CI via two version bumps.

@ocharles
Copy link
Copy Markdown
Owner

ocharles commented Dec 8, 2021

LGTM, thanks! I've split your CI commit out separately.

@ocharles ocharles enabled auto-merge (squash) December 8, 2021 14:58
@ocharles ocharles merged commit a05945b into ocharles:master Dec 8, 2021
@amesgen amesgen deleted the top-level-patterns branch December 8, 2021 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive (and possibly negative) with top level pattern matching

2 participants