Jump to page: 1 2
Thread overview
[Issue 22327] [Templates] arguments of T[] literals work for exactly one initialization before being set in stone
Nov 04, 2021
Paul Backus
Nov 04, 2021
Paul Backus
Nov 05, 2021
mhh
Dec 17, 2022
Iain Buclaw
September 22, 2021
https://issues.dlang.org/show_bug.cgi?id=22327

--- Comment #1 from crazymonkyyy@gmail.com ---
Created attachment 1828
  --> https://issues.dlang.org/attachment.cgi?id=1828&action=edit
:D

disregard its a feature not a bug
```
struct foo(T,T[] data){
        enum data_=data;
}
unittest{
        struct sercret{
                enum message="i like cake";
        }
        foo!(sercret,[]) bar;
}
unittest{
        alias leet=typeof(foo!(int,[]).data_[0]);
        import std.stdio;
        leet.message.writeln;
}
```

```
1 monkyyy@no ~/src/statemachines (git)-[master] % dmd -unittest -main -run
leethax.d
i like cake
```

--
September 22, 2021
https://issues.dlang.org/show_bug.cgi?id=22327

crazymonkyyy@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|nobody@puremagic.com        |crazymonkyyy@gmail.com

--
September 22, 2021
https://issues.dlang.org/show_bug.cgi?id=22327

crazymonkyyy@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WORKSFORME

--
September 22, 2021
https://issues.dlang.org/show_bug.cgi?id=22327

Steven Schveighoffer <schveiguy@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |schveiguy@gmail.com
         Resolution|WORKSFORME                  |---

--- Comment #2 from Steven Schveighoffer <schveiguy@gmail.com> ---
This is still a legitimate bug.

--
September 22, 2021
https://issues.dlang.org/show_bug.cgi?id=22327

crazymonkyyy@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |NEW

--- Comment #3 from crazymonkyyy@gmail.com ---
please dont break my workflow https://github.com/crazymonkyyy/monkyyy_templates

--
September 22, 2021
https://issues.dlang.org/show_bug.cgi?id=22327

crazymonkyyy@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |crazymonkyyy@gmail.com

--
November 04, 2021
https://issues.dlang.org/show_bug.cgi?id=22327

Paul Backus <snarwin+bugzilla@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |snarwin+bugzilla@gmail.com
           Hardware|x86_64                      |All
                 OS|Linux                       |All
           Severity|enhancement                 |normal

--
November 04, 2021
https://issues.dlang.org/show_bug.cgi?id=22327

--- Comment #4 from Paul Backus <snarwin+bugzilla@gmail.com> ---
Example program (simplified from attached "minimized" example):

---
template foo(T, T[] somedata_) {}

alias bar = foo!(int, [1, 2, 3]);
alias faz = foo!(string, ["a", "b", "c"]);
---

Expected behavior: compiles successfully.

Actual behavior: fails to compile, with the following error message:

---
Error: template instance `foo!(string, ["a", "b", "c"])` does not match
template declaration `foo(T, int[] somedata_)`
---

Removing the line `alias bar = foo!(int, [1, 2, 3]);` causes compilation to
succeed.

--
November 05, 2021
https://issues.dlang.org/show_bug.cgi?id=22327

mhh <maxhaton@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxhaton@gmail.com

--- Comment #5 from mhh <maxhaton@gmail.com> ---
------------------
TemplateInstance.findBestMatch()
foo(T, T[] somedata_) @ 0x7fe5e3c38810 hash is 781bbdffb091
        ++foo(T, T[] somedata_)
        It's a match with template declaration 'foo(T, int[] somedata_)'
        ++foo(T, int[] somedata_) at end of scope
------------------

Inside findBestMatch it looks like the template is considered and (for the first time round) matches successfully, but the process of doing this actually changes the TemplateDeclaration itself as shown above (see the difference between the two lines marked with pluses).

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=22327

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
« First   ‹ Prev
1 2