Skip to content

HIE file doesn't mention function referred to in left section with -XGHC2021

Summary

The use of a section doesn't produce a corresponding reference in the generated .hie file.

Steps to reproduce

Take the following as Wat.hs:

module Wat where 
wat x = (x &&)

Then compile this using:

ghc --make -fwrite-ide-info -XGHC2021 Wat.hs

Finally inspect the generated Wat.hie using hiedb dump:

$ hiedb dump Wat.hie
Node@Wat.hs:2:1-14: Source: From source
                    {(annotations: {(Module, Module), (AbsBinds, HsBindLR),
                                    (FunBind, HsBindLR), (Match, Match)}), 
                     (types: [3]),  (identifier info: {})}
                    
  Node@Wat.hs:2:1-3: Source: From source
                     {(annotations: {}),  (types: []), 
                      (identifier info: {(name wat,  Details:  Just 3 {LHS of a match group,
                                                                       regular value bound with scope: ModuleScope bound at: Wat.hs:2:1-14})})}
                     
  Node@Wat.hs:2:5: Source: From source
                   {(annotations: {(VarPat, Pat)}),  (types: [0]), 
                    (identifier info: {(name x,  Details:  Just 0 {bound in a pattern with scope: LocalScope Wat.hs:2:7-14 , NoScope })})}
                   
  Node@Wat.hs:2:7-14: Source: From source
                      {(annotations: {(GRHS, GRHS)}),  (types: []), 
                       (identifier info: {})}
                      
    Node@Wat.hs:2:9-14: Source: From source
                        {(annotations: {(HsPar, HsExpr)}),  (types: []), 
                         (identifier info: {})}
                        
      Node@Wat.hs:2:10-13: Source: From source
                           {(annotations: {(XExpr, HsExpr), (HsApp, HsExpr)}),  (types: [2]), 
                            (identifier info: {})}
                           
        Node@Wat.hs:2:10: Source: From source
                          {(annotations: {(HsVar, HsExpr)}),  (types: [0]), 
                           (identifier info: {(name x,  Details:  Just 0 {usage})})}

Notice that there is a {usage} for x, but no usage for &&.

If we change `wat to be a right section:

wat x = (&& x)

Then we get

Node@Wat.hs:2:1-14: Source: From source
                    {(annotations: {(Module, Module), (AbsBinds, HsBindLR),
                                    (FunBind, HsBindLR), (Match, Match)}), 
                     (types: [3]),  (identifier info: {})}
                    
  Node@Wat.hs:2:1-3: Source: From source
                     {(annotations: {}),  (types: []), 
                      (identifier info: {(name wat,  Details:  Just 3 {LHS of a match group,
                                                                       regular value bound with scope: ModuleScope bound at: Wat.hs:2:1-14})})}
                     
  Node@Wat.hs:2:5: Source: From source
                   {(annotations: {(VarPat, Pat)}),  (types: [0]), 
                    (identifier info: {(name x,  Details:  Just 0 {bound in a pattern with scope: LocalScope Wat.hs:2:7-14 , NoScope })})}
                   
  Node@Wat.hs:2:7-14: Source: From source
                      {(annotations: {(GRHS, GRHS)}),  (types: []), 
                       (identifier info: {})}
                      
    Node@Wat.hs:2:9-14: Source: From source
                        {(annotations: {(HsPar, HsExpr)}),  (types: []), 
                         (identifier info: {})}
                        
      Node@Wat.hs:2:10-13: Source: From source
                           {(annotations: {(XExpr, HsExpr), (HsApp, HsExpr)}),  (types: [2]), 
                            (identifier info: {})}
                           
        Node@Wat.hs:2:10-11: Source: From source
                             {(annotations: {(HsVar, HsExpr)}),  (types: [3]), 
                              (identifier info: {(name &&,  Details:  Just 3 {usage})})}
                             
        Node@Wat.hs:2:13: Source: From source
                          {(annotations: {(HsVar, HsExpr)}),  (types: [0]), 
                           (identifier info: {(name x,  Details:  Just 0 {usage})})}

which clearly mentions &&.

If we compile with -XHaskell2010, all is well:

ghc --make -fwrite-ide-info -XGHC2021 Wat.hs
Node@Wat.hs:2:1-14: Source: From source
                    {(annotations: {(Module, Module), (AbsBinds, HsBindLR),
                                    (FunBind, HsBindLR), (Match, Match)}), 
                     (types: [3]),  (identifier info: {})}
                    
  Node@Wat.hs:2:1-3: Source: From source
                     {(annotations: {}),  (types: []), 
                      (identifier info: {(name wat,  Details:  Just 3 {LHS of a match group,
                                                                       regular value bound with scope: ModuleScope bound at: Wat.hs:2:1-14})})}
                     
  Node@Wat.hs:2:5: Source: From source
                   {(annotations: {(VarPat, Pat)}),  (types: [0]), 
                    (identifier info: {(name x,  Details:  Just 0 {bound in a pattern with scope: LocalScope Wat.hs:2:7-14 , NoScope })})}
                   
  Node@Wat.hs:2:7-14: Source: From source
                      {(annotations: {(GRHS, GRHS)}),  (types: []), 
                       (identifier info: {})}
                      
    Node@Wat.hs:2:9-14: Source: From source
                        {(annotations: {(HsPar, HsExpr)}),  (types: []), 
                         (identifier info: {})}
                        
      Node@Wat.hs:2:10-13: Source: From source
                           {(annotations: {(XExpr, HsExpr), (HsApp, HsExpr)}),  (types: [2]), 
                            (identifier info: {})}
                           
        Node@Wat.hs:2:10: Source: From source
                          {(annotations: {(HsVar, HsExpr)}),  (types: [0]), 
                           (identifier info: {(name x,  Details:  Just 0 {usage})})}
                          
        Node@Wat.hs:2:12-13: Source: From source
                             {(annotations: {(HsVar, HsExpr)}),  (types: [3]), 
                              (identifier info: {(name &&,  Details:  Just 3 {usage})})}

If we change wat to have two arguments:

wat x y = (x && y)
``

Then we get

... Node@Wat.hs:2:12: Source: From source {(annotations: {(HsVar, HsExpr)}), (types: [0]), (identifier info: {(name x, Details: Just 0 {usage})})}

    Node@Wat.hs:2:14-15: Source: From source
                         {(annotations: {(HsVar, HsExpr)}),  (types: [3]), 
                          (identifier info: {(name &&,  Details:  Just 3 {usage})})}
                         
    Node@Wat.hs:2:17: Source: From source
                      {(annotations: {(HsVar, HsExpr)}),  (types: [0]), 
                       (identifier info: {(name y,  Details:  Just 0 {usage})})}

Likewise, if we remove all arguments from `wat`:

```haskell
wat = (&&)

We get

Node@Wat.hs:2:1-10: Source: From source
                    {(annotations: {(Module, Module), (AbsBinds, HsBindLR),
                                    (FunBind, HsBindLR), (Match, Match)}), 
                     (types: [3]),  (identifier info: {})}
                    
  Node@Wat.hs:2:1-3: Source: From source
                     {(annotations: {}),  (types: []), 
                      (identifier info: {(name wat,  Details:  Just 3 {LHS of a match group,
                                                                       regular value bound with scope: ModuleScope bound at: Wat.hs:2:1-10})})}
                     
  Node@Wat.hs:2:5-10: Source: From source
                      {(annotations: {(GRHS, GRHS)}),  (types: []), 
                       (identifier info: {})}
                      
    Node@Wat.hs:2:7-10: Source: From source
                        {(annotations: {(HsVar, HsExpr)}),  (types: [3]), 
                         (identifier info: {(name &&,  Details:  Just 3 {usage})})}

Expected behavior

The expression

wat x = (x &&)

should produce {usage} nodes mentioning both x and (&&).

Environment

  • GHC version used: 9.2.6

Optional:

  • Operating System: NixOS
  • System Architecture: x86_64-linux
Edited by Ollie Charles
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information