Skip to content

Module name in `module Hello where` is missing in the hieAst

Summary

ModuleName identifier is missing in the hieAst

Steps to reproduce

hello.hs

module Hello where

go = "1"

ghc hello.hs -fno-code -fwrite-ide-info -fvalidate-ide-info -ddump-hie -fforce-recomp > result.txt

[1 of 1] Compiling Hello            ( hello.hs, nothing )

==================== HIE AST ====================
File: hello.hs
Node@hello.hs:3:1-8: Source: From source
                     {(annotations: {(FunBind, HsBindLR), (Match, Match),
                                     (Module, Module), (XHsBindsLR, HsBindLR)}), 
                      (types: [0]),  (identifier info: {})}
                     
  Node@hello.hs:3:1-2: Source: From source
                       {(annotations: {}),  (types: []), 
                        (identifier info: {(name Hello.go,  Details:  Just 0 {LHS of a match group,
                                                                              regular value bound with scope: ModuleScope bound at: hello.hs:3:1-8})})}
                       
  Node@hello.hs:3:4-8: Source: From source
                       {(annotations: {(GRHS, GRHS)}),  (types: []), 
                        (identifier info: {})}
                       
    Node@hello.hs:3:6-8: Source: From source
                         {(annotations: {(HsLit, HsExpr)}),  (types: [0]), 
                          (identifier info: {})}
                         

Expected behavior

Expect to get a node with an identifier moduleName Hello.

Use case

The use case of this is in haskell language server when computing semantic tokens, we are giving semantic token type to the identifier from the hieAst to enable semantic highlighting. Missing moduleName Hello introduce inconsistency when we generate semantic token type for module name. See relevant discussion in https://github.com/haskell/haskell-language-server/discussions/4055#discussioncomment-8583290

Edited by Patrick
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information