-
-
Notifications
You must be signed in to change notification settings - Fork 610
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 20053 - add mixin types #10215
Conversation
|
Thanks for your pull request, @WalterBright! Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#10215" |
|
@TurkeyMan FYI |
|
home/circleci/dmd/src/dmd/typesem.d(1893): Error: template instance |
|
Thank you so much. This is really good. |
|
Yah, it was a rather glaring gap in the mixin capability. |
1434478 to
cbbcfc1
Compare
|
I'll try to get it through the test suite tomorrow. |
|
Please add the following to a fail_compilation test: struct Foo {
alias T = mixin("T2");
}
alias T1 = mixin("Foo.T");
alias T2 = mixin("T1");
void func (T2 p) {}Or any similar test with circular reference |
|
@Geod24 Nice thinking :) |
e9a9ac2 to
f761ac9
Compare
|
Spec: dlang/dlang.org#2684 |
e385c19 to
3cd3c22
Compare
| return a; | ||
| } | ||
|
|
||
| return new TypeMixin(arraySyntaxCopy(exps)); |
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.
I'm confused as to why this idiom was used here. It's just a more complicated way of saying... this:
override Type syntaxCopy()
{
Expressions* a = null;
if (exps)
{
a = new Expressions(exps.dim);
foreach (i, e; *exps)
{
(*a)[i] = e ? e.syntaxCopy() : null;
}
}
return new TypeMixin(a);
}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.
Because arraySyntaxCopy is used all over dmd, but is not available in astbase.d
src/dmd/parse.d
Outdated
| */ | ||
| RootObject parseTypeOrAssignExp() | ||
| { | ||
| return (isDeclaration(&token, NeedDeclaratorId.no, TOK.reserved, null)) |
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.
superfluous parens
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.
Please also add a test for multiple arguments to mixin (e.g. mixin("a", ".", "b");)
| @@ -6413,6 +6413,7 @@ extern (C++) class TemplateInstance : ScopeDsymbol | |||
| if (ta) | |||
| { | |||
| //printf("type %s\n", ta.toChars()); | |||
|
|
|||
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.
Unrelated
| { | ||
| return isDeclaration(&token, NeedDeclaratorId.no, TOK.reserved, null) | ||
| ? parseType() // argument is a type | ||
| : parseAssignExp(); // argument is an expression |
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.
Would have been better if this refactoring was in another PR
| // https://dlang.org/spec/expression.html#mixin_types | ||
| nextToken(); | ||
| if (token.value != TOK.leftParentheses) | ||
| error("found `%s` when expecting `%s` following %s", token.toChars(), Token.toChars(TOK.leftParentheses), "`mixin`".ptr); |
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.
| error("found `%s` when expecting `%s` following %s", token.toChars(), Token.toChars(TOK.leftParentheses), "`mixin`".ptr); | |
| error("found `%s` when expecting `%s` following `mixin`", token.toChars(), Token.toChars(TOK.leftParentheses)); |
|
This has been merged without
Same standards for everyone please. |
Don't need it.
|
Not necessary due to common handling with other mixins. It's only necessary to test what is different. |
|
changelog PR and we're good. Something inside this folder |
This line is not shared, and what I wanted to have covered by tests. |
|
That line looks green to me, and |
Currently D has these mixins:
But lacks types. This adds mixin types. I.e. adding:
to https://dlang.org/spec/declaration.html#BasicType