Behavior of literal `null`

I’ve finally gotten around to implementing the null literal. Here’s my current plan. Feedback would be much appreciated.

  • If null is specified in a context that expects a pointer of any kind, that pointer type is returned by the literal.
  • If null is specified with no expected type, or with an expected type that is not a pointer, compilation error will happen.


  • Simple.
  • Avoids C++ somewhat awkward nullptr_t type.


  • Too simple?
  • Doesn’t allow user-defined types to accept a generic null.

Please let me know what you think.

I can set it to be Void@ (pointer to void), and define a conditional implicit cast to all other pointer types if the VRP says it is null.

That will also work.