Expressions such as A(pointer(nil)) crashed the compiler when A is
a distinct pointer type. This is now fixed.
Details
Said expression reached cgirgen as (LvalueConv (Type "A") (NilLit)),
and since NilLit is not expected as the operand of an lvalue
conversion, the compiler crashed. distinct ptr types weren't
affected, due to semfold unconditionally folding ptr conversions
away. A(nil) was not affected due to transf folding the expression
into just a nil literal as part of its tyNil fixup.
In order to make pointer conversion behaviour consistent, semfold now
folds all nil-to-pointer-like conversions into a properly typed nil
literal. The tyNil fixup logic in transf thus becomes obsolete, and
is removed.
Beyond fixing the crash, this also means that pointer(nil) is now
detected as a constant expression without having to evaluate it with
the VM.
Summary
Expressions such as
A(pointer(nil))
crashed the compiler whenA
is adistinct pointer
type. This is now fixed.Details
Said expression reached cgirgen as
(LvalueConv (Type "A") (NilLit))
, and sinceNilLit
is not expected as the operand of an lvalue conversion, the compiler crashed.distinct ptr
types weren't affected, due tosemfold
unconditionally foldingptr
conversions away.A(nil)
was not affected due totransf
folding the expression into just anil
literal as part of itstyNil
fixup.In order to make pointer conversion behaviour consistent,
semfold
now folds all nil-to-pointer-like conversions into a properly typednil
literal. ThetyNil
fixup logic intransf
thus becomes obsolete, and is removed.Beyond fixing the crash, this also means that
pointer(nil)
is now detected as a constant expression without having to evaluate it with the VM.