Skip to content

Comments

[style.alias_syntax] Add AutoFix replacement#975

Merged
WebFreak001 merged 1 commit intodlang-community:masterfrom
ntrel:alias-fix
Feb 18, 2026
Merged

[style.alias_syntax] Add AutoFix replacement#975
WebFreak001 merged 1 commit intodlang-community:masterfrom
ntrel:alias-fix

Conversation

@ntrel
Copy link
Contributor

@ntrel ntrel commented Feb 1, 2026

Using alias target ident; syntax will be an error in the 2024 edition: dlang/dmd#22244. (Perhaps legacy.alias_syntax might be a better setting key than style.alias_syntax, though maybe best not to change it if tools depend on the current name.)

This should handle all cases of old alias syntax:

    alias StorageClassesopt BasicType TypeSuffixesopt Identifiers ;
    alias StorageClassesopt BasicType FuncDeclarator ;

There is a PR to update druntime/src. Although that was made using an updated dfix, I've checked the diff from this dscanner change and the only differences are on 2 lines where the trailing whitespace before ; is different. I don't think they matter much.

Also extend assertAnalyzerWarnings tests.

I also made a tokenStr function - I'm not sure if a similar equivalent exists somewhere, it seems a useful general function.


Enhancement: When the target is a function pointer/delegate and there are multiple identifiers, it can generate long lines even when the original line was not too long. See the LPCCHOOKPROC part of the description here. That mentions either using newlines before each identifier or changing the target for the remaining identifiers to the first identifier. Either of those should be straightforward to implement. The same can happen with other complicated targets. There could be a heuristic to enable different formatting when the target string length is more than e.g. 20.

@ntrel
Copy link
Contributor Author

ntrel commented Feb 16, 2026

I don't know why one of the tests is failing, maybe unrelated.

Copy link
Member

@WebFreak001 WebFreak001 left a comment

Choose a reason for hiding this comment

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

thanks, looks great and fully tested!

@WebFreak001 WebFreak001 merged commit 457fab8 into dlang-community:master Feb 18, 2026
30 of 32 checks passed
ntrel added a commit to ntrel/phobos that referenced this pull request Feb 20, 2026
I used
[dscanner](dlang-community/D-Scanner#975).

Needed as dlang/dmd#22244 was merged.
ntrel added a commit to ntrel/phobos that referenced this pull request Feb 20, 2026
I used
[dscanner](dlang-community/D-Scanner#975).

Needed as dlang/dmd#22244 was merged.
thewilsonator pushed a commit to dlang/phobos that referenced this pull request Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants