feat: Add compiler warning framework with opt-in rich warning rendering#1659
Draft
feat: Add compiler warning framework with opt-in rich warning rendering#1659
Conversation
Contributor
Contributor
|
| Branch | ss/push-kvqpqswszwxo |
| Testbed | Linux |
Click to view all benchmark results
| Benchmark | hugr_bytes | Benchmark Result bytes x 1e3 (Result Δ%) | Upper Boundary bytes x 1e3 (Limit %) | hugr_nodes | Benchmark Result nodes x 1e3 (Result Δ%) | Upper Boundary nodes x 1e3 (Limit %) |
|---|---|---|---|---|---|---|
| tests/benchmarks/test_big_array.py::test_big_array_compile | 📈 view plot 🚷 view threshold | 158.77 x 1e3(0.00%)Baseline: 158.77 x 1e3 | 160.36 x 1e3 (99.01%) | 📈 view plot 🚷 view threshold | 6.64 x 1e3(0.00%)Baseline: 6.64 x 1e3 | 6.71 x 1e3 (99.01%) |
| tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile | 📈 view plot 🚷 view threshold | 27.53 x 1e3(0.00%)Baseline: 27.53 x 1e3 | 27.81 x 1e3 (99.01%) | 📈 view plot 🚷 view threshold | 1.07 x 1e3(0.00%)Baseline: 1.07 x 1e3 | 1.08 x 1e3 (99.01%) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1659 +/- ##
==========================================
+ Coverage 93.54% 93.55% +0.01%
==========================================
Files 133 134 +1
Lines 12640 12757 +117
==========================================
+ Hits 11824 11935 +111
- Misses 816 822 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6d05861 to
9143b27
Compare
a9570d0 to
a4a1b20
Compare
a4a1b20 to
74aefe0
Compare
tatiana-s
reviewed
Apr 15, 2026
mark-koch
reviewed
Apr 15, 2026
Comment on lines
+22
to
+27
| # File path passed through to Python's warning machinery, if available. | ||
| filename: str | None | ||
| # 1-based source line passed through to Python's warning machinery, if available. | ||
| lineno: int | None | ||
| # 0-based source column used only for deduplicating distinct warnings on one line. | ||
| column: int | None |
Collaborator
There was a problem hiding this comment.
Consider using the existing Span class instead
mark-koch
reviewed
Apr 15, 2026
|
|
||
| rich_warnings: bool = False | ||
| pending_warnings: list[PendingWarning] = field(default_factory=list) | ||
| seen_warnings: set[_WarningKey] = field(default_factory=set) |
Collaborator
There was a problem hiding this comment.
It would be very cool if we could use set[Warning] here, it already includes the span and the message
This would require hashability, but maybe we can just force the new Warning subclass to be hashable instead of all Diagnostics?
This file contains hidden or 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
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.
Closes #1654
This adds the base compiler warning framework for guppylang. Warnings are now first-class non-fatal diagnostics that are buffered across a top-level check() or compile() operation, deduplicated within that operation, and emitted through Python’s warnings system as guppylang.GuppyWarning.
The change also adds an opt-in rich warning mode via with guppylang.rich_warnings(): .... In that mode, Guppy still emits the normal Python warning for filtering/tooling compatibility, and additionally renders the full warning diagnostic with source context to stderr.
What’s included:
Unreachable-code warning production in follow up: #1660
Developed iteratively with Codex, see individual commits for steps.