Compiler bug? Named parameters and others, or am I remembering wrong?

I have:

   type Clear_Colour_Ptr is access procedure (Red, Green, Blue, Alpha : Float32) with
     Convention => C;

   Clear_Colour : Clear_Colour_Ptr := null;

In a package, Clear_Colour get initialised by a generic function from SDL called Get_Subprogram.

I later use it:

      GL.Clear_Colour (Red, Alpha => 1.0, others => 0.0);
                                        ^

But get a compiler error:

first.adb:28:41: error: extra "," ignored
first.adb:28:43: error: positional parameter association not allowed after named one

I was certain this was allowed.

Hereā€™s the compiler:

$ alr build -- -v
warn: Generating possibly incomplete configuration because of missing dependencies
ā—· Syncing build dir... warn: Generating possibly incomplete environment because of missing dependencies
ā“˜ Running pre-build actions for sdlada=2.5.73...                               
make: Entering directory '/home/laguest/src/mine-new/game-dev/sdl/sdlada/build/gnat'
mkdir -p gen/src/
make: Leaving directory '/home/laguest/src/mine-new/game-dev/sdl/sdlada/build/gnat'
ā“˜ Building first=0.1.0-dev/first.gpr...
Changing to object directory of "First": "/home/laguest/src/mine-new/self-learning/cgpiogl/ch2/first/obj/development/"
/home/laguest/.local/share/alire/toolchains/gnat_native_14.1.3_965c1e0e/bin/gcc -c -x ada -gnatA -Og -ffunction-sections -fdata-sections -g -gnatwa -gnatw.X -gnatVa -gnaty3 -gnatya -gnatyA -gnatyB -gnatyb -gnatyc -gnaty-d -gnatye -gnatyf -gnatyh -gnatyi -gnatyI -gnatyk -gnatyl -gnatym -gnatyn -gnatyO -gnatyp -gnatyr -gnatyS -gnatyt -gnatyu -gnatyx -gnatW8 -gnat2022 -gnatyM120 -gnatec=/tmp/GNAT-TEMP-000003.TMP -gnatem=/tmp/GNAT-TEMP-000004.TMP /home/laguest/src/mine-new/self-learning/cgpiogl/ch2/first/src/first.adb
first.adb:28:41: error: extra "," ignored
first.adb:28:43: error: positional parameter association not allowed after named one

   compilation of first.adb failed

gprbuild: *** compilation phase failed
error: Command ["gprbuild", "-s", "-j0", "-p", "-P", "/home/laguest/src/mine-new/self-learning/cgpiogl/ch2/first/first.gpr", "-v"] exited with code 4
error: Compilation failed.

Also get the same error with my own 13.2.1, and alireā€™s 13.2.2.

I feel like itā€™s a bug but I donā€™t know offhand. You could potentially try something quick on Godbolt and select an older compiler to see if it is consistent

Iā€™d toss something up myself but on my phone so hard to type out code

Nope, failed on all.

I think the others => syntax only applies in a record context? If thatā€™s the issue, what a misleading error message! The late Robert Dewar always welcomed error reports about this sort of thing.

3 Likes

Thatā€™s probably it. I took a look and the RM specifies others in the record aggregate syntax but not in the subprogram call syntax.

Side note but ā€œothersā€ isnā€™t in the RM index oddly

Yeah, I found others to be missing from the index. So, Iā€™m remembering wrong then?

I think so yeah. Compare sections 6.4 and 4.3.1 of the RM. 4.3.1 explicitly mentions others while 6.4 doesnā€™t

The best place to find out where a particular piece of syntax is allowed is in the Syntax Summary:

http://ada-auth.org/standards/2yaarm/html/AA-P-1.html

An ā€œothersā€ is allowed in a number of places, but not in a call.

3 Likes

I dunno why I thought it could be. Seems like it could be useful. :pouting_cat:

For uniformityā€™s sake, I suppose allowing an ā€œothersā€ might be appropriate. But personally, it seems like a losing proposition, since you are not using the defaults, and you are losing the information provided by parameter names, so it would be a pain for the reader of your code to go and figure out which are the parameters all being passed this one value.

3 Likes