Skip to content

Commit

Permalink
fix for null check with mixed typed argument
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmisek committed May 22, 2023
1 parent 531bcf0 commit cadd6b4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/Peachpie.CodeAnalysis/Symbols/Source/SourceParameterSymbol.cs
Expand Up @@ -26,7 +26,7 @@ internal sealed class SourceParameterSymbol : ParameterSymbol
/// Index of the source parameter, relative to the first source parameter.
/// </summary>
readonly int _relindex;

ImmutableArray<AttributeData> _attributes;

TypeSymbol _lazyType;
Expand Down Expand Up @@ -55,7 +55,7 @@ public override FieldSymbol DefaultValueField
if (_lazyDefaultValueField == null && Initializer != null && ExplicitDefaultConstantValue == null)
{
TypeSymbol fldtype; // type of the field

if (Initializer is BoundArrayEx arr)
{
// special case: empty array
Expand Down Expand Up @@ -191,6 +191,17 @@ public override bool HasNotNull
return false;
}

if (_syntax.TypeHint is PrimitiveTypeRef ptref)
{
switch (ptref.PrimitiveTypeName)
{
case PrimitiveTypeRef.PrimitiveType.never:
case PrimitiveTypeRef.PrimitiveType.mixed:
// can be null
return false;
}
}

//
return true;
}
Expand Down Expand Up @@ -301,7 +312,7 @@ public override ImmutableArray<SyntaxReference> DeclaringSyntaxReferences
}

public override ImmutableArray<AttributeData> GetAttributes() => _attributes;

internal override IEnumerable<AttributeData> GetCustomAttributesToEmit(CommonModuleCompilationState compilationState)
{
// [param]
Expand Down

0 comments on commit cadd6b4

Please sign in to comment.