Skip to content

Prelude.head: empty list eval result when main function present  #4139

Closed
@mattapet

Description

@mattapet

Your environment

OS: macOS 13.2.1 (22D68)
GHC: 9.8.1, and 9.8.2
LSP: 2.2.0.0, 2.5.0.0, 2.6.0.0, 2.7.0.0, and head
LSP Plugin: hls-eval-plugin

Steps to reproduce

I tried a number of of combinations of GHC/LSP/file setup, but it seems that with GHC 9.8.x any time when there's a main function present in the module, the result after evaluation is Prelude.head: empty list.

E.g.

module Test where

-- >>> 'x'

main :: IO ()
main = putStrLn "Hello World!"

Expected behaviour

module Test where

-- >>> 'x'
-- 'x'

main :: IO ()
main = putStrLn "Hello World!"

Actual behaviour

module Test where

-- >>> 'x'
-- Prelude.head: empty list

main :: IO ()
main = putStrLn "Hello World!"

Debug information

After a bit of debugging myself, I found the error originating from this use of head. After a bit of tinkering, it seems that the underlying hscParsedDecls function, which TyThings output is [Identifier `$trModule'], rather than the expected [Identifier `evalPrint', Identifier `$trModule'].

As the problem seems to arise from the GHC, I am not quite sure whether there's a bug in GHC, or Eval plugin implementation is working under the wrong assumptions.

I am happy to try to fix this if someone is able to provide some additional direction/advice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: hls-eval-plugintype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions