haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Signature Help should provide signature in the `do` notation

Open fendor opened this issue 1 month ago • 3 comments

It looks like no signature help is provided when the AST node is in a do notation block:

Image

You can see in the logs, the rules were triggered, but no signature help was provided. If I change the code in question to not use do-notation, then signature help works as expected:

Image

Happened on GHC 9.10.3

fendor avatar Nov 27 '25 09:11 fendor

cc @jian-lin, this is probably just a matter of expanding the correct AST nodes, I assume?

fendor avatar Nov 27 '25 09:11 fendor

Nice catch. I can have a look ~tomorrow~ the day after tomorrow.

this is probably just a matter of expanding the correct AST nodes, I assume?

I am not sure currently. Dumping the AST (haskell-language-server hiedb dump) may help.

jian-lin avatar Nov 27 '25 10:11 jian-lin

Facts

I can reproduce this in GHC 9.10.2 and 9.12.2. This issue does not exist in GHC 9.6.7 and 9.8.4.

The direct cause is a HIE AST change introduced in 9.10. Here is the HIE AST node of expected (Node@/path/to/haskell-language-server/hls-test-utils/src/Test/Hls.hs:400:47-54:) in different versions.

GHC 9.6.7 and 9.8.4:

Source: From source
(annotations: {(HsVar,
                HsExpr)}), 
(types: [413]), 
(identifier info: {(name expected,  Details:  Just 413 {usage})})}

GHC 9.10.2 and 9.12.2:

Source: From source
{(annotations: {(HsVar,
                 HsExpr)}), 
 (types: []), 
 (identifier info: {(name expected,  Details:  Nothing {usage})})}
Source: generated by ghc
{(annotations: {(HsVar,
                 HsExpr)}), 
 (types: [437]), 
 (identifier info: {(name expected,  Details:  Just 437 {usage})})}

We can see that, besides the expected identifier From source, there is a new expected identifier generated by ghc. And all type info is moved to the generated by ghc identifier from the From source identifier.

Next step

Before modifying related code in HLS to fix this, I think we should first figure out if this HIE AST change is intended or is a GHC bug. Mayebe @wz1000 can share some pointers.

jian-lin avatar Nov 30 '25 06:11 jian-lin