D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 15665 - Templated scope class with constructor don't compile
Summary: Templated scope class with constructor don't compile
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-09 20:18 UTC by Mathias Lang
Modified: 2016-03-14 14:43 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Mathias Lang 2016-02-09 20:18:00 UTC
The following code:

```
scope class Foo (V)
{
    this () {}
}

void main ()
{
    scope f = new Foo!(Object);
}
```

Results in:
```
scope_class.d(3): Error: functions cannot return scope scope_class.Foo!(Object)
scope_class.d(8): Error: template instance scope_class.Foo!(Object) error instantiating
```

Which is obviously wrong. Not providing a constructor, or making the class a non-template works as expected. That's a D1 regression.

Tested with 2.066, 2.069, 2.070
Comment 2 github-bugzilla 2016-02-10 03:48:17 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/4a38b1d326ef8e48289309863f35d36c6d9c4e20
Fix issue #15665: Templated scope class with constructor doesn't compile

While instantiating a template, FuncDeclaration::semantic3 will call into
TypeFunction::semantic, but the flags SCOPEctor is only set during
CtorDeclaration::semantic.

https://github.com/D-Programming-Language/dmd/commit/c32ccb7c12c53d230d722d4e9b2414b38c3097bf
Merge pull request #5432 from mathias-lang-sociomantic/fix-15665

Fix issue #15665: Templated scope class with constructor doesn't compile
Comment 3 github-bugzilla 2016-03-02 09:36:17 UTC
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e8c4f5ed9124a3e18081699789ad5cd6efc7aa94
Fix issue #15665: Templated scope class with constructor doesn't compile

While instantiating a template, FuncDeclaration::semantic3 will call into
TypeFunction::semantic, but the flags SCOPEctor is only set during
CtorDeclaration::semantic.

https://github.com/D-Programming-Language/dmd/commit/83be084357b5529d3d9fa2338c8bffb6fa3862c8
Merge pull request #5493 from Dicebot/pick-15665

Cherry-pick fix for issue 15665 into stable
Comment 4 github-bugzilla 2016-03-14 14:43:23 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e8c4f5ed9124a3e18081699789ad5cd6efc7aa94
Fix issue #15665: Templated scope class with constructor doesn't compile

https://github.com/D-Programming-Language/dmd/commit/83be084357b5529d3d9fa2338c8bffb6fa3862c8
Merge pull request #5493 from Dicebot/pick-15665