# An interesting case of name resolution

**URL:** https://forum.ada-lang.io/t/an-interesting-case-of-name-resolution/4734
**Category:** General
**Created:** [September 12, 2026, 6:19pm UTC](https://forum.ada-lang.io/t/an-interesting-case-of-name-resolution/4734 "2026-09-12T18:19:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dmitry-kazakov](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/dmitry-kazakov/32/522_2.png) [@dmitry-kazakov](https://forum.ada-lang.io/u/dmitry-kazakov)
#### Post date: [September 12, 2026, 6:19pm UTC](https://forum.ada-lang.io/t/an-interesting-case-of-name-resolution/4734/1 "2026-09-12T18:19:41Z")

</div>

Consider this:

```ada
procedure Visibility is
   package Q is
      type T is abstract tagged null record;
      function "&" (Left, Right : T) return T is abstract;
      function "&" (Left, Right : Integer) return T is abstract;
   end Q;
   package R is
      use Q;
      type S is new T with null record;
   private
      overriding function "&" (Left, Right : S) return S;
      overriding function "&" (Left, Right : Integer) return S;
   end R;
   package body R is -- The body is irrelevant
      function "&" (Left, Right : S) return S is
      begin
         return S'(null record);
      end "&";
      function "&" (Left, Right : Integer) return S is
      begin
         return S'(null record);
      end "&";
   end R;
   use R;
   X : Q.T'Class := (1 & 2) & (3 & 4); -- This is fine
begin
   null;
end Visibility;

```

Now, let’s change it to this (just adding `use Q`):

```ada
   use Q, R;
   X : T'Class := (1 & 2) & (3 & 4); -- Error!

```

GNAT 16.2 gives:

```ada
visibility.adb:25:27: error: ambiguous expression (cannot resolve "&")
visibility.adb:25:27: error: possible interpretation (inherited) at line 9
visibility.adb:25:27: error: possible interpretation at line 4
gnatmake: "visibility.adb" compilation error

```

It seems that an **abstract** primitive function (line 4) gets considered in resolution of “&”! This is quite surprizing to me, but I do not know if the compiler is correct here.

---

<div class="post-metadata">

### Author: ![Nordic\_Dogsledding](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/nordic_dogsledding/32/547_2.png) [@Nordic\_Dogsledding](https://forum.ada-lang.io/u/Nordic_Dogsledding)
#### Post date: [September 13, 2026, 3:53am UTC](https://forum.ada-lang.io/t/an-interesting-case-of-name-resolution/4734/2 "2026-09-13T03:53:35Z")

</div>

> [@dmitry-kazakov](#):
>
> `use Q, R; X : T'Class := (1 & 2) & (3 & 4); -- Error!`

use Q, R;  
X : T’Class := R.S’(1 & 2) & (3 & 4); – OK again

I’m sorry, but I also cannot tell whether GNAT is right in rejecting the code.  
It might have to do with dispatching, calling abstract operations must be dispatching, but here there is no dispatching.

```ada
  use Q, R;
  Y1: Q.T'Class := R.S'(1 & 2);
  Y2: Q.T'Class := R.S'(3 & 4);
  --Z : Q.T'Class := Y1 & (3 & 4); --visibility.adb:48:27: error: call to abstract function must be dispatching
-- | col 27
  Z : Q.T'Class := Y1 & Y2; -- now dispatching and OK

```
