8000 Store warnings in a set rather than a list by andreasabel · Pull Request #7478 · agda/agda · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Store warnings in a set rather than a list #7478

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

Merged
merged 6 commits into from
Sep 14, 2024
Merged

Store warnings in a set rather than a list #7478

merged 6 commits into from
Sep 14, 2024

Conversation

andreasabel
Copy link
Member
@andreasabel andreasabel commented Sep 9, 2024

Currently we store warnings in a list and have some hacks to prevent duplicate warnings.
Also, to join warning lists we use List.union which has a weird semantics.
It would be more natural to use a Set for warnings.

Currently we lack an Ord instance for TCWarning since Doc does not have one.
So here I cache the rendering of the warning doc as tcWarningString to facilitate an Ord instance.
The warnings should be ordered by position so the first component in the ordering is the Range of the warning.

WIP: For reasons very unclear to me, this first component is ignored, or the ranges there are mysteriously empty, so the warnings are ordered by the string rendering of their position.
I already tried to make sure that the ranges are serialized, but to no avail.
I need some help in debugging this.
Thanks @plt-amy !

New features:

  • print range also for UnsolvedMeta and UnsolvedConstraints warnings (the latter often does not have a range, though)
  • separate NonFatalErrors by newlines

8000
@andreasabel andreasabel added refactor Changes to the code base which do not affect users (not in changelog) ux: warnings Issues relating to the reporting of warnings labels Sep 9, 2024
@andreasabel andreasabel added this to the 2.8.0 milestone Sep 9, 2024
@andreasabel andreasabel self-assigned this Sep 13, 2024
@andreasabel andreasabel added the pr: squash-me This PR needs squashing label Sep 13, 2024
SafeFlagPragma xs -> fsep $ concat
[ [ fsep $ pwords "Cannot set OPTIONS" ++ [ pluralS (words =<< xs) "pragma" ] ]
SafeFlagPragma sset -> vcat $ concat
[ [ fwords $ singPlural (words =<< xs) id (++ "s") "The --safe mode does not allow OPTIONS pragma" ]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check whether this rewording isn't a regression.

let sfp = case foldMap pragmas ws of
(TCWarning loc r w doc str b : _, sfp) ->
singleton $ TCWarning loc r (SafeFlagPragma sfp) doc str b
_ -> empty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get rid entirely of this special logic for SafeFlagPragma? One of these possibilities:

  1. Make SafeFlagPragma take a single pragma name rather than a Set.
  2. Store the SafeFlagPragma warning separately so that in the state these warnings are always properly aggregated.

Seems like 1. would be simplest.
Ad 2: We might want to aggregate other warnings as well (at least those that are deserialized), so we should have a uniform mechanism for that rather than this special case for SafeFlagPragma.

@@ -1,6 +1,3 @@
Issue5029.agda:1,1-45: warning: -W[no]WarningProblem
You may only turn off benign warnings. The warning TerminationIssue is a non-fatal error and thus cannot be ignored. See --help=warning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed duplicate.
Missing newline between warning and error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline between warning and error.

Cannot find the code position where to fix this.

MdSpanningComment.lagda.md:10,3-16,7: Multi-line comment spans one or more literate text blocks.
error: [OverlappingTokensWarning]
MdSpanningComment.lagda.md:2,4-6,19: Multi-line comment spans one or more literate text blocks.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing range for this error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attempt to fix this in #7492.

If `f` has inverse `g`, then check `g x ∈ s` is often faster then `x ∈ fmap f s`.
@andreasabel andreasabel added pr: preserve commits PR should be merged via rebase, preserving the commits and removed pr: squash-me This PR needs squashing labels Sep 13, 2024
@andreasabel andreasabel force-pushed the warning-set branch 3 times, most recently from f274684 to 6f4715a Compare September 14, 2024 08:56
@andreasabel andreasabel removed the refactor Changes to the code base which do not affect users (not in changelog) label Sep 14, 2024
This ensures that warnings we register twice are not printed twice.
Also, the warnings are printed in order of their range.
Now they will be printed in order of their Range.
@andreasabel andreasabel marked this pull request as ready for review September 14, 2024 09:46
@andreasabel andreasabel merged commit a387237 into master Sep 14, 2024
40 checks passed
@andreasabel andreasabel deleted the warning-set branch September 17, 2024 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: preserve commits PR should be merged via rebase, preserving the commits ux: warnings Issues relating to the reporting of warnings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0