-
-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Issue 13732 - non-member templates can use "template this" #14434
Changes from 6 commits
c22f40b
11c0eb1
88fdc35
f6878c9
a4ee2a4
0fb4622
31f49e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/templatethis.d(11): Error: cannot use `this` outside an aggregate type | ||
fail_compilation/templatethis.d(15): Error: cannot use `this` outside an aggregate type | ||
fail_compilation/templatethis.d(19): Error: cannot use `this` outside an aggregate type | ||
fail_compilation/templatethis.d(21): Error: cannot use `this` outside an aggregate type | ||
--- | ||
*/ | ||
|
||
template t(this T) | ||
{ | ||
} | ||
|
||
struct S(this T) | ||
{ | ||
} | ||
|
||
enum e(this T) = 1; | ||
|
||
void f(this T)() | ||
{ | ||
} | ||
|
||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/templatethis.d(34): Error: cannot use `this` outside an aggregate type | ||
fail_compilation/templatethis.d(37): Error: mixin `templatethis.t2!()` error instantiating | ||
--- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a fan of breaking up the TEST_OUTPUT directives, if the diagnostic were to change in the future, then it can't be updated in an automated way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (cannot be updated... yet) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: There are 85 files in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And they are annoying to deal with as one must manually work out where to update them when diagnostics change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree that it's better to just group all the error messages into a single There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ibuclaw OK, I see. Fixed! |
||
*/ | ||
mixin template t2() | ||
{ | ||
int i(this T) = 1; | ||
} | ||
|
||
mixin t2; | ||
|
||
class C | ||
{ | ||
static void f(this T)() {} | ||
} | ||
|
||
alias a = C.f!int; // FIXME error | ||
alias b = C.f!C; // OK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
#line
for stable line numbers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, then the error message line numbers don't match up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is the point, adding/removing a line doesn't affect the entire output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
#line
is also annoying since the error line that is reported does not match up the editor line and you can't just:linenumber