Skip to content

Commit

Permalink
Fix Issue 21898 - Qualifier ignored in alias definition if parenthese…
Browse files Browse the repository at this point in the history
…s are not present
  • Loading branch information
BorisCarvajal authored and thewilsonator committed May 7, 2021
1 parent da751c2 commit f991372
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/dmd/dsymbolsem.d
Expand Up @@ -6536,8 +6536,11 @@ void aliasInstanceSemantic(TemplateInstance tempinst, Scope* sc, TemplateDeclara

TemplateTypeParameter ttp = (*tempdecl.parameters)[0].isTemplateTypeParameter();
Type ta = tempinst.tdtypes[0].isType();
Declaration d = new AliasDeclaration(tempinst.loc, ttp.ident, ta.addMod(tempdecl.onemember.isAliasDeclaration.type.mod));
d.storage_class |= STC.templateparameter;
auto ad = tempdecl.onemember.isAliasDeclaration();

// Note: qualifiers can be in both 'ad.type.mod' and 'ad.storage_class'
Declaration d = new AliasDeclaration(tempinst.loc, ttp.ident, ta.addMod(ad.type.mod));
d.storage_class |= STC.templateparameter | ad.storage_class;
d.dsymbolSemantic(sc);

paramscope.pop();
Expand Down
7 changes: 7 additions & 0 deletions test/compilable/test21898.d
@@ -0,0 +1,7 @@
// https://issues.dlang.org/show_bug.cgi?id=21898

alias Works(T) = immutable(T);
alias Fails(T) = immutable T;

static assert(is(Works!int == immutable int));
static assert(is(Fails!int == immutable int));

0 comments on commit f991372

Please sign in to comment.