AdaCore / libadalang-tools

Libadalang-based tools
GNU General Public License v3.0
16 stars 13 forks source link

gnatpp crashes when setting -c3 to format commments and comment has no characters #29

Open dalybrown opened 12 months ago

dalybrown commented 12 months ago

I'm trying to pretty print some generated code from a tool I don't have control over. It generates comments using only a single space between the delimiter and the start of the comment. The style enforced by alire and gnat require two spaces. This seems like a good job for the pretty printer. However, it crashes immediately, even for the most basic example.

Here is a file (test.ads):

--
-- Test
--
package Test is end;

If I run the pretty printer on it using the following command:

gnatpp -c3 test.ads

It just raises an exception and quits:

Unhandled Exception raised
raised ADA.ASSERTIONS.ASSERTION_ERROR : pp-formatting.adb:310

If you don't have the extra delimiters, it works fine:

-- Test

package Test is end;

I'm using version 23.0.0 of the tool: https://github.com/alire-project/alire-index/blob/stable-1.2.1/index/li/libadalang_tools/libadalang_tools-23.0.0.toml.

It should handle the case where comments are surrounded by delimiters (unless it does and I'm missing a setting).