Skip to content

gnatformat removes space between attribute and argument list (e.g., 'Length (1)) #7

@Heziode

Description

@Heziode

Description

I have encountered an issue where gnatformat incorrectly removes the whitespace between an Ada attribute (such as 'Length) and its argument list (the opening parenthesis).

While the formatter correctly handles the insertion of spaces before parentheses in other contexts (e.g., function calls), it seems to force the removal of the space when applied to attributes.

Steps to Reproduce

  1. Create a file with the following code (note the space between 'Length and (1)):
function Count_Pieces (Board : Board_Type; State : Square_State_Type) return Natural
with Ghost, Post => Count_Pieces'Result <= Board'Length (1) * Board'Length (2);
  1. Run gnatformat on this file.

Actual Behavior

The formatter removes the spaces, resulting in:

function Count_Pieces (Board : Board_Type; State : Square_State_Type) return Natural
with Ghost, Post => Count_Pieces'Result <= Board'Length(1) * Board'Length(2);

Expected Behavior

The formatter should preserve (or insert) the space before the opening parenthesis to maintain consistency with the rest of the code style, looking like this:

function Count_Pieces (Board : Board_Type; State : Square_State_Type) return Natural
with Ghost, Post => Count_Pieces'Result <= Board'Length (1) * Board'Length (2);

Additional Context

This issue seems specific to attributes. In other scenarios, the rule regarding "space before parenthesis" appears to be applied correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions