Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions spec/type.dd
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,25 @@ $(H2 $(LNAME2 void, $(D void)))
see $(RELATIVE_LINK2 pointer-conversions, Pointer Conversions).
* $(DDSUBLINK spec/arrays, void_arrays, Void arrays).
* $(DDSUBLINK spec/expression, cast_void, Ignoring a value) by casting to `void`.
* The type of a symbol resolving to a $(GLINK2 template, TemplateDeclaration).
* The type of a non-eponymous $(GLINK2 template, TemplateInstance).

$(SPEC_RUNNABLE_EXAMPLE_COMPILE
--------------------
void f();
static assert(is(typeof(f()) == void));

void* ptr;
static assert(is(typeof(ptr[0]) == void));

template t() {}
static assert(is(typeof(t) == void));
static assert(is(typeof(t!()) == void));
--------------------
)

$(RATIONALE To simplify the grammar, an expression can resolve to a template or
template instantiation. A valid expression must have a valid type.)

$(P `void.sizeof` is 1 (not 0).)

Expand Down Expand Up @@ -1020,15 +1039,6 @@ $(H3 $(LNAME2 typeof-special, Special Cases))
typeof(S.foo) n; // n is declared to be an int
--------------------

$(P If the expression is a $(DDLINK spec/template, Template, Template),
$(D typeof) gives the type $(D void).
)

--------------------
template t {}
static assert(is(typeof(t) == void));
--------------------


$(H2 $(LNAME2 mixin_types, Mixin Types))

Expand Down
Loading