Fix Issue 9701 - allow UDAs to be attached to enum values#8404
Fix Issue 9701 - allow UDAs to be attached to enum values#8404dlang-bot merged 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request and interest in making D better, @IgorStepanov! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. 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#8404" |
src/dmd/denum.d
Outdated
| Type origType; | ||
|
|
||
| EnumDeclaration ed; | ||
| bool isdeprecated; |
There was a problem hiding this comment.
FYI: We now have an official D style which we try to follow for new variables.
So this would be isDeprecated
There was a problem hiding this comment.
Base class Dsymbol already has a virtual method isDeprecated(). And some classes e.g. AggregateDeclaration has a field isdeprecated, which is returned by overridden method isDeprecated().
Maybe stay it as is?
There was a problem hiding this comment.
Hmm, I guess _deprecated or _isDeprecated or isDeprecatedEnum would be better than having a symbol which only differences in the spelling?
BTW isdeprecated is only set once and never looked at, which looks a bit suspicious.
There was a problem hiding this comment.
BTW isdeprecated is only set once and never looked at, which looks a bit suspicious.
Yeah, may be a leftover of some debugging I was doing. @IgorStepanov, please investigate if it's actually needed.
There was a problem hiding this comment.
Ok, I've just removed it:)
| */ | ||
| extern (C++) final class VarExp : SymbolExp | ||
| { | ||
| bool hasCheckedAttrs; |
There was a problem hiding this comment.
It's a little naughty, but I don't know of any other solution, and it'd be a shame to hold up this feature on such a minor problem, so OK, let's do it. I do, however, suggest adding a comment explaining why this exists.
|
We probably need to update the language spec also. I'll try to get to it later, but I won't mind if someone beats me to it. |
ee289ed to
da07d98
Compare
|
BTW, What purpose of |
Keep in mind that I had been playing with that code for a very long time, trying many different things to work through the problem. If you find that the |
AstBase is used nowhere in DMD. It was an attempt by @RazvanN7 to separate the AST nodes and create a pure "data" layer. |
|
I suggest adhering to the YAGNI principle. In other words, if it's not used, remove it from both constructors. |
It needed in |
Done |
| { | ||
| // Semantic can be called many times for a one expression. | ||
| // This field need to ensure that deprecation message will be printed only one time. | ||
| bool hasCheckedAttrs; |
There was a problem hiding this comment.
Changes for proper English grammar:
// Semantic can be called multiple times for a single expression.
// This field is needed to ensure the deprecation message will be printed only once.
|
It looks good to me. I would like to hear from @RazvanN7 about the discrepancy with |
|
Spec PR: dlang/dlang.org#2396 |
src/dmd/expression.d
Outdated
| */ | ||
| extern (C++) final class VarExp : SymbolExp | ||
| { | ||
| // Semantic can be called many times for a one expression. |
There was a problem hiding this comment.
Please make this a Ddoc comment. All public or protected symbols should have a documentation, i.e. a Ddoc comment.
| @@ -0,0 +1,24 @@ | |||
| D now supports attributes on enum members | |||
|
|
|||
There was a problem hiding this comment.
Perhaps explicitly list the supported attributes since it's only three (counting UDAs as one) and to avoid any confusion.
jacob-carlborg
left a comment
There was a problem hiding this comment.
Looks good, just a few minor comments.
|
@JinShil @jacob-carlborg All comments resolved. Any other objections? |
As far as I understand, ASTBase was introduced to allow using the parser without the rest of the frontend. Using the rest of the frontend as a library caused some problems. Those are fixed and the full frontend is available as a library. I don't think there's a need for ASTBase. |
jacob-carlborg
left a comment
There was a problem hiding this comment.
I'll approve this and if there's a need to update ASTBase we can do that in a followup PR.
|
Thanks! |
Reboot of #8319
@JinShil @jacob-carlborg Let finish it.