-
Notifications
You must be signed in to change notification settings - Fork 11
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
Parse File ... not found
messages
#297
Draft
9999years
wants to merge
6
commits into
main
Choose a base branch
from
rebeccat/dux-2341-parse-module-not-found-messages
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9999years
force-pushed
the
rebeccat/dux-2341-parse-module-not-found-messages
branch
from
June 21, 2024 20:15
7a91ede
to
2bb67b8
Compare
This was referenced Jun 21, 2024
9999years
added a commit
that referenced
this pull request
Jun 21, 2024
This is useful for line-oriented parsers that may consume input with no trailing newline character. While this is a [violation of the POSIX spec][posix], VS Code [does it by default][vscode]. [posix]: https://stackoverflow.com/a/729795 [vscode]: https://stackoverflow.com/questions/44704968/visual-studio-code-insert-newline-at-the-end-of-files Split off from #297
Previously, a `ModuleSet` wrapped a `HashMap<NormalPath, TargetKind>`. This had a number of undesirable consequences: * The data about a module's name (as its path) and how it was loaded (as its `TargetKind`) were split from each other and difficult to reference. * The module's import name wasn't explicitly stored anywhere, so we needed to convert between paths and dotted names when those were needed, which required hitting the disk. * There wasn't a type for the module's import name, so when we (e.g.) `:unadd`ed modules we needed to format them as strings. Now, a `ModuleSet` wraps a `HashSet<LoadedModule>`. * A `LoadedModule` wraps a path but optionally contains the module's dotted name, if the module is loaded by name (and needs to be referred to by name to avoid the "module defined in multiple files" error). * The `LoadedModule` `Display` instance formats the module's import name correctly (with a dotted name if needed) and avoids hitting the disk or any string processing.
9999years
force-pushed
the
rebeccat/refactor-module-set
branch
from
June 21, 2024 20:58
a93cc3f
to
ffde017
Compare
GHC output contains quoted fragments: Module graph contains a cycle: module ‘C’ (./C.hs) imports module ‘A’ (A.hs) which imports module ‘B’ (./B.hs) which imports module ‘C’ (./C.hs) When Unicode output is not available, the Unicode quotes are substituted for GNU-style ASCII quotes: module `C' (./C.hs) However, when the quoted text starts or ends with a single quote, ASCII quotes are omitted. This leads to ambiguous output: A → `A' A' → A' `A' → `A' 'A → 'A 'A' → 'A' Correctly parsing this is challenging. This probably increases the amount of backtracking and lookahead required for these parsers. Not sure if that's significant or relevant.
Haskell source paths, as GHC understands them, are remarkably permissive: they must end with one of the source extensions (now more accurately listed here, with references to the upstream GHC code), but can otherwise contain quirks up to and including multiple extensions, whitespace, and newlines. GHCi is actually even more lenient than this in what it accepts; it'll automatically append `.hs` and `.lhs` to paths you give it and check if those exist, but fortunately they get printed out in `:show targets` and diagnostics as the resolved source paths: ```text ghci> :add src/MyLib [1 of 1] Compiling MyLib ( src/MyLib.hs, interpreted ) ghci> :show targets src/MyLib.hs ghci> :add src/Foo target ‘src/Foo’ is not a module name or a source file ghci> :add src/MyLib.lhs File src/MyLib.lhs not found ghci> :add "src/ Foo.hs" File src/ Foo.hs not found ghci> :add "src\n/Foo.hs" File src /Foo.hs not found ```
This will help us keep the module set in sync more reliably.
9999years
force-pushed
the
rebeccat/dux-2341-parse-module-not-found-messages
branch
from
June 21, 2024 21:05
2bb67b8
to
492bfa1
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This will help us keep the module set in sync more reliably.
Depends on:
ModuleSet
: store a set rather than a map #292[NFCI] Unwrap
GhcMessage
in diagnostic parsers #299[NFCI] Use
line_ending_or_eof
consistently in parsers #300Parse single-quoted GHC output more reliably #301
Parse Haskell source paths more reliably #302
Labeled the PR with
patch
,minor
, ormajor
to request a version bump when it's merged.Updated the user manual in
docs/
.Added integration / regression tests in
tests/
.