Skip to content

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

@zaneduffield

Description

@zaneduffield

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:

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:

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions