[Issue 19056] UDAs can be added to imports but not retrieved

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 9 19:16:36 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19056

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com
           Severity|minor                       |enhancement

--- Comment #5 from Walter Bright <bugzilla at digitalmars.com> ---
First off, I agree that aliases should be aliases, not modifications to other
symbols. I.e. attributes must not affect the alias. (Changing this behavior
will have far reaching consequences in the internal compiler implementation,
and would be at risk of a lot of unexpected corner cases.)

As to making:

  @X alias g = a; // (1)

illegal (as opposed to simply ignoring the @X), consider:

  @X { alias g = a; } // (2)
  @Y: alias g = a; // (3)

Making those illegal will cause problems. Then the issue is should (1) be
rejected as a special case while ignoring the attributes in (2) and (3)? This
behavior isn't the case anywhere else. The three forms are equivalent, it's an
easy rule to remember, and easy to have a consistent, correct implementation.

We'd be trading "why don't attributes affect the alias" to "why does the
attribute syntax have different behavior w.r.t. aliases"? Is that a net
improvement?

Therefore I'm opposed to adding a special case to reject (1). The compiler is
working as intended and designed.

(I also changed it to "Enhancement", because the compiler is working as
designed.)

Note that a similar issue has come up recently with:

   int foo(scope int x)

Should 'scope' be an error or be ignored? The answer is ignored, because making
it an error would make writing generic code awkward, clumsy, and ugly.

--


More information about the Digitalmars-d-bugs mailing list