integrated-application-development / integrated-application-development/pasfmt

Unit names in uses clause should never be wrapped onto multiple lines

Open
#249 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
105
Forks
20
PR merge metrics
No merged PRs in 30d

Description

Something I noticed when looking at #248 was that the compiler doesn't tolerate unit names in uses clauses that are split onto multiple lines:
```delphi
uses
System
.SysUtils; // E2004 Identifier redeclared: 'System'
```

This seems like a compiler bug (and I may raise an quality portal issue for it), because in other contexts it's perfectly valid to split the segments of the unit name on separate lines:
```delphi
System
.SysUtils
.Format('', []);
```

While it's unusual for unit names to be long enough to wrap *and* be using namespaces, it's still a real issue that people could encounter because lines can be too long due to comments:
```delphi
uses
System.Generics.Collections; // aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

## Workarounds

1. disable formatting for the section (`{pasfmt off}`, `{pasfmt on}`)
2. move any trailing comments to a different position
3. skip the namespace for the unit and add it as a [unit scope name](https://docwiki.embarcadero.com/RADStudio/en/Unit_Scope_Names)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.