Issue 5416 & 5889 - typeof(null) should have a type of its own #476

Merged
merged 2 commits into from Nov 25, 2011

Projects

None yet

3 participants

@9rnsr
Member
9rnsr commented Oct 27, 2011

Issue 5416 - null should have a type of its own
Issue 5899 - auto-return function cannot match 'null' with reference type.

typeof(null) should have the own type, that is implicitly convertible to any reference types.
In binary level, typeof(null) is treated as void*

I think this is also useful for NonNull!T, because we can reject NonNull!T p = null; statically.

@tgehr tgehr and 1 other commented on an outdated diff Nov 14, 2011
src/mtype.c
+ to->ty == Tdelegate)
+ return MATCHconst;
+ }
+
+ return MATCHnomatch;
+}
+
+void TypeNull::toDecoBuffer(OutBuffer *buf, int flag)
+{
+ //tvoidptr->toDecoBuffer(buf, flag);
+ Type::toDecoBuffer(buf, flag);
+}
+
+void TypeNull::toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs)
+{
+ buf->writestring("null_t");
@tgehr
tgehr Nov 14, 2011 Contributor

I think this should be
buf->writestring("typeof(null)");

@9rnsr
9rnsr Nov 15, 2011 Member

It's better.

@WalterBright WalterBright merged commit 31a3e40 into dlang:master Nov 25, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment