`gnatformat` removes space between attribute and argument list (e.g., `'Length (1)`)
Nobody has claimed this yet.
- Dominant language
- Ada
- Stars
- 21
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
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
- Create a file with the following code (note the space between
'Lengthand(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);
- Run
gnatformaton 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the Ada declaration and postcondition shown in the report, then trace gnatformat's handling of attribute references followed by parentheses. Done means formatting preserves or inserts a space between attributes such as 'Length and their argument lists, matching the expected output.
Written by the indexing model from the issue text.
Assessment
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100