Skip to content

[style.alias_syntax] Add AutoFix replacement#975

Open
ntrel wants to merge 1 commit intodlang-community:masterfrom
ntrel:alias-fix
Open

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

Conversation

@ntrel
Copy link

@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.

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.

1 participant