diff --git a/compiler/ncnv.pas b/compiler/ncnv.pas index 7a99797870..6e20d6fc3f 100644 --- a/compiler/ncnv.pas +++ b/compiler/ncnv.pas @@ -4071,8 +4071,13 @@ implementation result:=nil; { Passing a class type to an "as" expression cannot result in a class of that type to be constructed. + + We could put this inside the if-block below, but this way it is + safe for sure even if the code below changes } - include(right.flags,nf_ignore_for_wpo); + if assigned(right) then + include(right.flags,nf_ignore_for_wpo); + if not assigned(call) then begin if is_class(left.resultdef) and