Skip to content

Commit f51aa99

Browse files
committed
Don't drop aggregate type qualifier for alias parameter
Fixes #17959.
1 parent 9132771 commit f51aa99

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

compiler/src/dmd/templatesem.d

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2656,7 +2656,10 @@ private MATCH matchArg(TemplateParameter tp, Scope* sc, RootObject oarg, size_t
26562656
//printf("TemplateAliasParameter.matchArg('%s')\n", tap.ident.toChars());
26572657
MATCH m = MATCH.exact;
26582658
Type ta = isType(oarg);
2659-
RootObject sa = ta && !ta.deco ? null : getDsymbol(oarg);
2659+
// Note: Dsymbol doesn't have qualifiers, so avoid if ta.mod is set
2660+
// https://github.com/dlang/dmd/issues/17959
2661+
RootObject sa = ta && !ta.deco ? null :
2662+
ta && ta.mod /*&& sc.hasEdition(Edition.v2024)*/ ? oarg : getDsymbol(oarg);
26602663
Expression ea = isExpression(oarg);
26612664
if (ea)
26622665
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module m 2024;
2+
3+
alias t(alias a) = a;
4+
5+
static assert(is(t!(const Object) == const Object));
6+
static assert(is(t!(shared(Object)) == shared Object));
7+
static assert(is(t!(immutable S) == immutable(S)));
8+
9+
struct S {}

0 commit comments

Comments
 (0)