Conversation
|
Thanks for your pull request and interest in making D better, @gorsing! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#22717" |
472a33a to
46ef580
Compare
|
@tgehr Thanks for the feedback! This is exactly the structural analysis I was hoping for. You've made excellent points. Transitioning to unusedParams: I completely agree that Manu's parameter usage check is a more high-value target for a PoC. I’ve integrated the core logic from @TurkeyMan's work into this pragma(lint) infrastructure. I will keep constSpecial as a secondary, strictly optional rule to further demonstrate how the system handles different semantic phases. Disabling individual checks: Agreed. For now, the implementation supports enabling specific rules or all of them. Granular "disable-only" toggling can be added as the list of rules grows. Diagnostic identifiers: I'll update the lint() reporting mechanism to explicitly include the rule identifier. This ensures developers know exactly which rule triggered the message (e.g., Lint[unusedParams]: ...). Hard Error: You’re right if a developer explicitly opts into a check via pragma, it should be treated with the same severity as any other language rule. I'll update ErrorKind.lint to increment global.errors. This aligns with D's philosophy of avoiding "ignored" warnings. |
8dab004 to
ebc93d8
Compare
6d7f5ec to
e3c9e82
Compare
* Refactoring add pragma lint (#72) * fix .h * Refactoring st3 (#65) * fix extern (C++) * Auto-update C++ headers via dtoh * make refactoring (#68) * Refactoring add pragma lint v6 (#70) * add unusedParams * add unusedParams * add unusedParams * add unusedParams * add unusedParams * add unusedParams * add unusedParams * add unusedParams * Refactoring add pragma lint v6 (#71) * Refactoring add pragma lint v5 (#69) * add unusedParams * add unusedParams * add unusedParams * add unusedParams * add unusedParams * add unusedParams * add unusedParams * add unusedParams * Refactoring add pragma lint v6 (#70) (#64) * add unusedParams * add unusedParams * add unusedParams * add unusedParams * add unusedParams * add unusedParams * add unusedParams * add unusedParams * update *.h * refactoring
eb2e904 to
890d23a
Compare
|
@rikkimax, since you proposed the pragma(lint) infrastructure, and @TurkeyMan, as you've done the heavy lifting on the unusedParams logic, I’d really value your input on this. I believe we can find a path that satisfies everyone’s requirements and helps D evolve. I’ve put together a functional prototype in #22717 that merges both approaches: it takes the core logic from the unused parameters PR and wraps it in a lexically scoped pragma. Having a concrete, testable implementation allows us to move past the philosophical debate and refine the actual mechanics. It’s designed to be strictly opt-in, posing no risk to existing codebases, while giving us a solid engine for higher quality standards—and perhaps eventually a way to safely modernize Phobos. I'd specifically appreciate your technical thoughts on the scope handling in the implementation. I want to ensure this foundation is robust enough for D's future linting needs. |
|
I don't want this to be part of semantic analysis; it is complicated enough as it is, without introducing an additional optional feature. It should be split out into its own package ( Split out any state into their own Line 303 in e563b43 To move forward on this, it'll need to go to a monthly meeting to discuss. This month's meeting, I wasn't in a good state to deal with it. I was barely able to attend, and by the end, I had been up 20+ hours. Good attempt at the idea, nonetheless. |
|
@rikkimax Thanks for the feedback! This is exactly the analysis I was hoping for. You made grate point comments. |
|
I'm quite unhappy that this has spun off from my issue in this way... I don't understand how this is any different than a warning, just presented in an unprecedented way. |
|
|
This does not fork the language into multiple dialects.
Just put |
I really don't care what it's called. The mechanism is what's important, and it's clearly you who is having an emotional reaction to terminology. x) |
I mean, I'm having an emotional reaction to arbitrarily renaming something that's established for at least half a century that everyone expects and understands for 'trendy'(?) reasons... I still just want selective |
|
Lint c linter 1978: http://squoze.net/UNIX/v7/files/doc/15_lint.pdf
What you define as trendy, is a term in active use with the same meaning as
today, before you were born.
Please listen to us compiler developers, we have insight that you cannot
get from usage alone.
…On Sat, 21 Mar 2026, 02:50 Manu Evans, ***@***.***> wrote:
*TurkeyMan* left a comment (dlang/dmd#22717)
<#22717 (comment)>
pragma(warn, constSpecial): - There... I fixed it. It seems we're dealing
with an emotional reaction to the word "warning". If you want pragma based
warning control, then add pragma(warn).
I really don't care what it's called. The mechanism is what's important,
and it's clearly you who is having an emotional reaction to terminology. x)
I mean, I'm having an emotional reaction to arbitrarily renaming something
that's established for at least half a century that everyone expects and
understands for 'trendy'(?) reasons...
I still just want selective -w though, although pragma(warn) is a
perfectly fine pursuit if you like it; I would use it in many situations.
—
Reply to this email directly, view it on GitHub
<#22717?email_source=notifications&email_token=AAHSL467BT4AF4D5VLS7JVL4RVEEBA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMBZHAYDSNZQGA3KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4098097006>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHSL45WMKMDNX32PF4MM4D4RVEEBAVCNFSM6AAAAACWM7NTSGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DAOJYGA4TOMBQGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Don't type It's a serious stretch to say a warning fork's the language; C/C++ adds a bunch of new warnings every release, and compilers also have their own different sets. I've never heard anybody complain about this; if one is too aggressive or incompatible, disable it, or don't-enable it. We've spent more time talking about this here now than I reckon I've struggled with warning management in a lifetime. |
Motivation
Currently, developers rely on external tools like D-Scanner to catch semantic anti-patterns and style issues. However, external AST-based linters lack access to the compiler's symbol table and type resolution, which leads to false positives/negatives for complex semantic rules.
At the same time, introducing new semantic checks as compiler warnings (
-w) has historically been rejected because it breaks existing codebases and CI pipelines.Solution
This PR introduces a dedicated, strictly opt-in linter infrastructure integrated directly into the frontend via
pragma(lint).ErrorKind.lintdiagnostic that strictly does not incrementglobal.errorsorglobal.warnings. Compiling with-wor-wewill never fail if a lint rule is triggered.pragma(lint, ruleName)integrates tightly withScopeand applies lexically. It can be toggled on/off (none,all) per-module, per-aggregate, or per-function, respecting D's philosophy of explicit control.SARIFoutput, making it ready for modern IDEs and CI/CD environments.Proof of Concept Rule (
constSpecial)To demonstrate the infrastructure, this PR includes one zero-false-positive rule:
constSpecial. It emits a lint message when special struct methods (opEquals,toHash,opCmp,toString) are declared withoutconst. Since this check sits insemantic3.d(visit(FuncDeclaration)), it leverages the compiler's perfect knowledge of types and correctly ignores compiler-generated thunks (!funcdecl.isGenerated()).Example usage:
Future Impact
If accepted, this lays the groundwork for migrating highly requested, semantically heavy checks (e.g., unused parameters, redundant expressions, catching base
Exceptionor UnusedParams) directly into the compiler, without disrupting the ecosystem or forcing warnings on users who don't want them.