Skip to content

Token parse error on {-# UNPACK #-} #1258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Vlix opened this issue Jan 24, 2021 · 3 comments · Fixed by #1232
Closed

Token parse error on {-# UNPACK #-} #1258

Vlix opened this issue Jan 24, 2021 · 3 comments · Fixed by #1232
Labels
component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@Vlix
Copy link

Vlix commented Jan 24, 2021

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

haskell-language-server version: 0.8.0.0 (GHC: 8.6.5) (PATH: /home/flix/.config/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.8.0-linux-8.6.5) (GIT hash: eb58f13f7b8e4f9bc771af30ff9fd82dc4309ff5)
Tool versions found on the $PATH
cabal:		2.4.1.0
stack:		2.5.1
ghc:		8.0.2

Which lsp-client do you use: VSCode
Describe your project (alternative: link to the project): https://github.com/yesodweb/wai/blob/master/warp/Network/Wai/Handler/Warp/Request.hs#L212
Contents of hie.yaml: none

Steps to reproduce

Expected behaviour

Should just parse the .hs file.

Actual behaviour

HLS fails to process the file. (Request.hs, see link to project)

Include debug information

LSP logs:
haskell-language-server-0.8.0-linux-8.6.5: Tokens.next failed to parse     {-# UNPACK #-} !Int -- running total byte count (excluding current header chunk) Parser did not consume entire stream, left: "!Int -- running total byte count (excluding current header chunk)"
CallStack (from HasCallStack):
  error, called at src/Ide/Plugin/Eval/Parse/Token.hs:134:19 in hls-eval-plugin-0.1.0.0-inplace:Ide.Plugin.Eval.Parse.Token
@Vlix
Copy link
Author

Vlix commented Jan 24, 2021

Might be related to this one?
#1160 (comment)

@jneira
Copy link
Member

jneira commented Jan 24, 2021

I think the problem is related with parser errors coming from the eval plugin (take look to latest issues labeled with)
And hopefully it will be fixed by #1232

@jneira jneira added component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jan 24, 2021
@konn
Copy link
Collaborator

konn commented Jan 26, 2021

I confirmed manually that this bug will be solved by #1232. I've just added the following test case to regression test:

{- | Won't panic on UNPACKs -}
module TUNPACK (THStatus(..)) where

type ByteString = String
type BSEndo = ByteString -> ByteString
type BSEndoList = [ByteString] -> [ByteString]

data THStatus = THStatus
    {-# UNPACK #-} !Int -- running total byte count
    BSEndoList -- previously parsed lines
    BSEndo -- bytestrings to be prepended

-- >>> "Yay! UNPACK pragma didn't do bad things!"

EDIT: ... And, of course, the above code fragments makes HLS 0.8.0, which doesn't include mentioned PR, hangs up as expected.

@mergify mergify bot closed this as completed in #1232 Jan 31, 2021
mergify bot pushed a commit that referenced this issue Jan 31, 2021
* WIP: Comment parsing using module annotations

* Line Comment parsers (wip)

* Line comment implemented (block comment not implemented)

* Completely switches to Megaparsec

* T27 must be fixed

* We can always assume that comment starts with "--" with no space prepended

* must be horizontal space, not ANY whitespace

* Block parser (WIP)

* We don't need whole range; position suffices

* Brutal parsing for block haddock comments

* Brutal line parsing

* unset Opt_Haddock

* Wrong debug messages

* Redundant debug output

* Hacks for indentation levels and LHS

* Updates block comment logic in Literate Haskell

* Updates doctests

* Allows doctest without newline at the end

* Precise handling of line ending

* Corrects last-line block eval handling

* Makes normal line parsing LHS sensitive

* Removes outdated note on block comments in a single line

* Wait a moment before executing each code lenses

* Sorting tests in order

* Sorts lenses in order

* Reverted to use executCmd

* Changes sorting logic

* Fixes test case: trailing space

* Dummy commit to re-invoke CI

* expect fail CPP Eval on Windows

* Corrects typo

* Test for #1258

* Corrects test header

* Ad-hoc treatment for ending brace in nested comment block

* `goldenTest` function from Eval plugin doesn't support multiple tests in the same block but in separate group

* Dummy commit to rerun CI

* Stop using CPP and use `knownBrokenForGhcVersions` and `knownBrokenOnWindows`

* Nested `expectedFailure` didn't work as expected

* Abolishes `Parser` type synonym

* Removes unneccesary comment evals

* Skip failed curentRange resolution

Co-authored-by: Junyoung/Clare Jang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants