Bug 8395 – Templated struct constructors don't implicitly convert to const

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-16T23:45:00Z
Last change time
2012-08-18T02:51:41Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
clugdbug
Blocks
4301

Comments

Comment #0 by clugdbug — 2012-07-16T23:45:37Z
struct S { int m; // this(long x) // this(T : long)( T x) const this(T : long)( T x) { m = x;} } void main() { S s = 6; const S t = 7; } bug.d(18): Error: template bug.S.__ctor does not match any function template declaration bug.d(11): Error: template bug.S.__ctor(T : long) cannot deduce template function from argument types !()(int) If the constructor signature is replaced with either of the two commented lines, it compiles.
Comment #1 by k.hara.pg — 2012-07-20T10:46:53Z
Comment #2 by github-bugzilla — 2012-07-23T01:39:06Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/86cfb07481ce37cb3dc8889597f4652887673f42 fix Issue 8395 - Templated struct constructors don't implicitly convert to const With current dmd implementation, non template constructor always ignores the type qualifier of 'this'. Therefore template constructor should work as like it. https://github.com/D-Programming-Language/dmd/commit/29c76d261fe81719addc0219c42b8fccc6562e88 Merge pull request #1060 from 9rnsr/fix8395 Issue 8395 - Templated struct constructors don't implicitly convert to const