dmd/compiler/test/fail_compilation/templatethis.d
Nick Treleaven a9ae71196b
Fix Issue 13732 - non-member templates can use "template this" (#14434)
* Fix Issue 13732 - non-member templates can use "template this"

* Ignore template this parameter inside a template as it could be a mixin

Note: Can't use goto to jump into scope(exit).

* Fix detecting aggregate template with TemplateThisParameter

* Remove parse changes

* Implement semantic checks for template this

* Remove error for explicit template this parameter not class or struct

* Merge error output, test mixin and remove static this for now
2022-10-04 05:19:21 +03:00

37 lines
733 B
D

/*
TEST_OUTPUT:
---
fail_compilation/templatethis.d(13): Error: cannot use `this` outside an aggregate type
fail_compilation/templatethis.d(17): Error: cannot use `this` outside an aggregate type
fail_compilation/templatethis.d(21): Error: cannot use `this` outside an aggregate type
fail_compilation/templatethis.d(23): Error: cannot use `this` outside an aggregate type
fail_compilation/templatethis.d(29): Error: cannot use `this` outside an aggregate type
fail_compilation/templatethis.d(32): Error: mixin `templatethis.t2!()` error instantiating
---
*/
template t(this T)
{
}
struct S(this T)
{
}
enum e(this T) = 1;
void f(this T)()
{
}
mixin template t2()
{
int i(this T) = 1;
}
mixin t2;
class C
{
mixin t2; // OK
}