[Issue 24521] New: Template value parameters are not visible outside

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 25 11:12:08 UTC 2024


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

          Issue ID: 24521
           Summary: Template value parameters are not visible outside
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: b2.temp at gmx.com

## test case

```d
struct S(int a) { }

void main()
{
    alias S1 = S!1;
    static assert(S1.a);
}          
```

## output

> t.d(6,19): Error: no property `a` for type `t.S!1`  
> t.d(1,1):        struct `S` defined here  
> t.d(6,5):        while evaluating: `static assert((S!1).a)`

## notes

I suspect that while I think this should work, the problem that's observed
could actually be related to "how template arguments are scoped" (so maybe an
implementation detail ?)

But this does not work either:

```d
template S(int a)
{
    struct S { }
}

void main()
{
    alias S1 = S!1;
    static assert(S1.a);
}   
```

--


More information about the Digitalmars-d-bugs mailing list