-
-
Notifications
You must be signed in to change notification settings - Fork 655
fix issue 10770 - is(T BASE==enum) with tag enum T - AssertFail:'type' line 428 declaration.c #2456
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
Conversation
There is an edge case, the following currently works but will fail with your pull: enum E : int;
static assert(is(E e == enum)); |
Using the following works for me: tded = ((TypeEnum *)targ)->toBasetype(); With these test-cases: enum E : int;
static assert(is(E e == enum));
enum F;
static assert(is(F e == enum)); Edit: Actually they both pass now, but you may be right that the second case should actually be disallowed. |
@9rnsr: What do you think, should both cases be allowed? |
In the |
Updated. |
@@ -33,6 +33,7 @@ | |||
defaultval = NULL; | |||
sinit = NULL; | |||
isdeprecated = false; | |||
hasexplicittype = false; |
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.
Adding hasexplicittype
looks weird to me.
I had thought that, if !members && !memtype
, the taking the base type would cause "forward reference" or "unknown size" error.
However by looking enum.c
now, I noticed that EnumDeclaration::getMemtype
returns Type::tint32
for the base type of enum E;
.
I think that the current EnumDeclaration::getMemtype
behavior would be a bug. Could you consider fixing the function rather than adding hasexplicittype
field?
Sorry for late reply. While testing your PR in my local, I noticed that it would be better not to cause "forward reference" error in Type *TypeEnum::toBasetype()
{
+ if (!sym->members && !sym->memtype)
+ return this;
return sym->getMemtype(Loc())->toBasetype();
} |
Please fix file name: |
@hpohl , Could you please add some comment when you update/push commits? If not, I cannot notice your change (Github doesn't send any notification emails to the review participants in such cases). |
line 428 declaration.c
Do you have any plan to fix issue 10770? If not, I'd open a new PR for the ICE bug. |
Posted #2795 |
#2795 was merged, so I close this. |
Sorry, will look into my other PRs next weekend. |
http://d.puremagic.com/issues/show_bug.cgi?id=10770