[Issue 19569] overload resolution not right?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 10 07:58:47 UTC 2019


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

Mike Franklin <slavo5150 at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slavo5150 at yahoo.com

--- Comment #4 from Mike Franklin <slavo5150 at yahoo.com> ---
I think what Jacob is saying is that `nothrow` will be inferred for templates
at the time of instantiation based on the context of the instatiation.

That means you should not create both `void foo(T)()` and `void foo(T)()
nothrow`.  When the template is instantiated the compiler will automatically
add `nothrow` to the instantiation if the context is `nothrow`.

The bug here may be that the compiler allowed you to declare both a `nothrow`
and non-`nothrow` template without error.  I suppose it should be an error to
add any inferred attribute to templates if they're going to inferred by the
caller.  Either that, or, if the user explicitly added an attribute to a
template, then inference for that attribute should be disabled at the time of
instantiation.

I can't say I approve of this attribute inference behavior -- I'd prefer to
have some mataprogramming facilities to control it -- but that's the way D
currently seems to work, so changing it would probably require a DIP.

--


More information about the Digitalmars-d-bugs mailing list