Bug 12676 – alias parameter attempts to interpret symbol

Status
REOPENED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-28T19:00:53Z
Last change time
2024-12-13T18:20:17Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Andrej Mitrovic
Moved to GitHub: dmd#17656 →

Comments

Comment #0 by andrej.mitrovich — 2014-04-28T19:00:53Z
I think this may be a valid bug report, unless I'm misunderstanding things: ----- class C { } template TemplAlias1( alias x = C // default ) { } template TemplAlias2( alias x : C // specialization ) { } template TemplAlias2( alias x : C = C // default = C, specializes to C ) { } void main() { alias a = TemplAlias1!(); alias b = TemplAlias2!(C); alias b = TemplAlias3!(); } ----- $ dmd test.d > test.d(12): Error: Cannot interpret C at compile time
Comment #1 by andrej.mitrovich — 2014-04-29T20:06:40Z
Sorry, the example is a bit wrong. Fixed: ----- template TemplAlias1( alias x = C // default ) { } template TemplAlias2( alias x : C // specialization ) { } template TemplAlias3( alias x : C = C // default = C, specializes to C ) { } void main() { alias a = TemplAlias1!(); alias b = TemplAlias2!(C); alias c = TemplAlias3!(); } -----
Comment #2 by andrej.mitrovich — 2014-04-29T20:23:56Z
Here: ----- class C { } class D : C { } template TemplAlias( alias x : D = C ) { } ----- For some reason in the parser isDeclaration() returns false for ": Type", but true for "= Type", and either a parseType() or a parseCondExp() is taken.Later in in the semantic phase the alias class tries to evaluate D as an expression rather than as a type so it fails.
Comment #3 by andrej.mitrovich — 2014-04-30T09:45:54Z
Not a bug, aliases work on literals and expressions, not types.
Comment #4 by andrej.mitrovich — 2014-04-30T09:49:31Z
Ok, the OP example wasn't supported, but this must be a bug: ----- template Templ1() { } template Templ2 ( alias T : Templ1 = Templ1, ) { } ----- test.d(5): Error: Cannot interpret Templ1() at compile time
Comment #5 by robert.schadek — 2024-12-13T18:20:17Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17656 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB