Skip to content
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

Ghci Script Target parses space in Filepath with space #162

Closed
fendor opened this issue Mar 16, 2020 · 2 comments · Fixed by #163
Closed

Ghci Script Target parses space in Filepath with space #162

fendor opened this issue Mar 16, 2020 · 2 comments · Fixed by #163
Assignees
Labels
type: bug Something isn't working

Comments

@fendor
Copy link
Collaborator

fendor commented Mar 16, 2020

Issue in hie: haskell/haskell-ide-engine#1669

Example: some ghci script:

:add Lib Lib2 "/home/user/Has kell/Test.hs"

is wrongfully parsed into targets: ["Lib", "Lib2", "\"home/user/Has", "kell/Test.hs\""].

Offending code: https://github.com/mpickering/hie-bios/blob/9fd8af352317490f1c68cb628b2ce2a8733b63e5/src/HIE/Bios/Environment.hs#L223

@fendor fendor added the type: bug Something isn't working label Mar 16, 2020
@fendor fendor self-assigned this Mar 16, 2020
@fendor
Copy link
Collaborator Author

fendor commented Mar 16, 2020

Proposed Solution: use attoparsec to parse these targets correctly.

attoparsec is already in the project dependency closure.

fendor added a commit to fendor/hie-bios that referenced this issue Mar 17, 2020
fendor added a commit to fendor/hie-bios that referenced this issue Mar 17, 2020
fendor added a commit to fendor/hie-bios that referenced this issue Mar 17, 2020
@fendor
Copy link
Collaborator Author

fendor commented Mar 17, 2020

For Documentation:
This happens when we are using a Stack cradle and have a executable component.
Assuming we have only an executable, then stack will produce a ghci-script with the following contents:

:add "<root-path>/Main.hs"

We parse this ghci-script to extract targets that we can load.

The previous parsing logic just used words to split this line into targets that we can load.
However, this breaks if the path contains a space.
The patch in #163 uses the parser from base to parse whitespace within quotes and allow escaped ".

fendor added a commit to fendor/hie-bios that referenced this issue Mar 17, 2020
fendor added a commit to fendor/hie-bios that referenced this issue Mar 17, 2020
mpickering pushed a commit that referenced this issue Mar 24, 2020
* Fix parsing of spaces in targets in ghci-scripts

* Add tests for issue #162

* Update documentation for parser function

* Improve parser logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant