Skip to content

Fix Issue 16611 - 'Unrecognized type const(void)' error for std.trait…#4916

Merged
andralex merged 1 commit intodlang:masterfrom
Darredevil:issue-16611
Nov 22, 2016
Merged

Fix Issue 16611 - 'Unrecognized type const(void)' error for std.trait…#4916
andralex merged 1 commit intodlang:masterfrom
Darredevil:issue-16611

Conversation

@Darredevil
Copy link
Contributor

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
16611 std.traits.fullyQualifiedName fails with error 'Unrecognized type const(void)'

@MetaLang
Copy link
Member

Please add one or more unittests testing this code path.

Copy link
Member

@PetarKirov PetarKirov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Darredevil

However I am not sure if this is the right approach. In theory shouldn't "const(void)" be caught by isBasicType ? Should I edit this one instead to check for const(void) as well ?

IMO, the correct fix, is to change isBasicType to:

enum bool isBasicType(T) = isScalarType!T || is(Unqual!T == void);

That would entail, adding a unittest to isBasicType for isBasicType!(const void), isBasicType!(shared void), etc. and then adding a tests to fullyQualifiedName for T == const(void) and friends.

@MetaLang
Copy link
Member

It's a little weird that you can create a type like const void or shared void in the first place... but it seems that DMD doesn't complain (except when you try to declare a variable of those types, of course).

@schveiguy
Copy link
Member

@MetaLang need it for declaring appropriate void arrays: const(void)[], shared(void)[], etc.

@MetaLang
Copy link
Member

Ah, for some reason I thought that was a separate case.

@Darredevil Darredevil force-pushed the issue-16611 branch 2 times, most recently from fd89d03 to 26f3f16 Compare November 22, 2016 00:51
@Darredevil
Copy link
Contributor Author

@ZombineDev @MetaLang Implemented the modifications you suggested. Should be ready for merge once all tests pass.

static assert(fqn!(dstring) == "dstring");
static assert(fqn!(void) == "void");
static assert(fqn!(const(void)) == "const(void)");
static assert(fqn!(shared(void)) == "shared(void)");
Copy link
Member

@MetaLang MetaLang Nov 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add tests for the following qualifiers:

shared const       void
shared inout       void
shared inout const void
inout              void
inout  const       void
immutable	   void

static assert(isBasicType!void);
static assert(isBasicType!(const(void)));
static assert(isBasicType!(shared(void)));
static assert(isBasicType!(immutable(void)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

@PetarKirov PetarKirov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @Darredevil! With that everything LGTM.

@MetaLang
Copy link
Member

LGTM

@andralex andralex merged commit 3fec190 into dlang:master Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants