Bug 12122 – Template with enumerated constant length array causes error.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-09T11:58:00Z
Last change time
2014-02-16T14:28:40Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
dy70swq+kzut3k

Attachments

IDFilenameSummaryContent-TypeSize
1323bugtest.dExample D2 code to generate the error together with what causes it.text/x-dsrc395

Comments

Comment #0 by dy70swq+kzut3k — 2014-02-09T11:58:18Z
Created attachment 1323 Example D2 code to generate the error together with what causes it. When foo function is used, compile time error is seen. bugtesr.d(16): Error: template bugtesr.Test.foo does not match any function template declaration. Candidates are: bugtesr.d(4): bugtesr.Test.foo(T)(in T[Test.DATA_LENGTH] msg) if (is(T : ubyte) || is(T : char)) bugtesr.d(16): Error: template bugtesr.Test.foo(T)(in T[Test.DATA_LENGTH] msg) if (is(T : ubyte) || is(T : char)) cannot deduce template function from argument types !()(ubyte[16]) If the constant DATA_LENGTH is replaced with its real value 16, it works without a problem.
Comment #1 by bearophile_hugs — 2014-02-09T12:27:46Z
Reduced: enum N = 1; void foo(T)(T[N]) if(is(T == int)) {} void main() { int[N] data; foo(data); }
Comment #2 by k.hara.pg — 2014-02-10T00:10:37Z
Comment #3 by github-bugzilla — 2014-02-16T10:46:11Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d17d5f1e7de00abda58596efc2ab34b4e066dfb8 fix Issue 12122 - Template with enumerated constant length array causes error https://github.com/D-Programming-Language/dmd/commit/788cef53e41b3753da49aab298a952172b9fb897 Merge pull request #3242 from 9rnsr/fix12122 Issue 12122 - Template with enumerated constant length array causes error
Comment #4 by andrej.mitrovich — 2014-02-16T14:28:40Z
P.S. Kenji sorry for not closing these myself, when I set to auto-merge I tend to do some other work and I miss the notification so the issue can be closed. I guess we could use some kind of auto-close feature as well.