[Issue 23620] 'alias this' is not respected in static array length position

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 17 03:36:25 UTC 2023


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

--- Comment #11 from Salih Dincer <salihdb at hotmail.com> ---
(In reply to Max Samukha from comment #9)
> (In reply to Salih Dincer from comment #8)
> > I don't understand too :)
> > 
> > This code works me:
> > 
> >   struct Index(T)
> >   {
> >     T value;
> >     
> >     this(T v) { value = v; };
> >     alias opCall this;
> >     
> >     @property opCall() inout {
> >       return value;
> >     }
> >     
> >   }
> >   
> >   enum one= Index!int(1)();
> >   int[one] a = 1;
> >   
> >   int[Index!int(2)()] b = 2;
> >   static assert(a.length < b.length);
> > 
> > Best regards...
> > 
> > SDB at 79
> 
> You don't need to mark opCall with @property for that code to work. 'alias
> this' is also unnecessary.
> 
> You wrote "This isn't a bug!". Did you mean this bug report is invalid? If
> yes, it would be nice if you explained why you think the report is invalid.

Here's how I think (please let's discuss privately via email or here):

First you create an object and it is a struct.  There is a strange working
alias in the build. The related problem may be a bug for you. But is there any
reason not neomorph it?  Because CTFE is involved.

But what if we don't want the object to occur where it occurs (in a variable
without CTFE) that it points to, not itself?

SDB at 79

--


More information about the Digitalmars-d-bugs mailing list