Skip to content

Commit

Permalink
diagnostic InvalidCastException fix
Browse files Browse the repository at this point in the history
fixes #151
  • Loading branch information
jakubmisek committed Jan 21, 2018
1 parent 659fa02 commit fce134f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Peachpie.CodeAnalysis/FlowAnalysis/DiagnosingVisitor.cs
Expand Up @@ -354,7 +354,8 @@ private void CheckUndefinedFunctionCall(BoundGlobalFunctionCall x)
var errmethod = (ErrorMethodSymbol)x.TargetMethod;
if (errmethod != null && errmethod.ErrorKind == ErrorMethodKind.Missing)
{
_diagnostics.Add(_routine, ((FunctionCall)x.PhpSyntax).NameSpan.ToTextSpan(), ErrorCode.WRN_UndefinedFunctionCall, x.Name.NameValue.ToString());
var span = x.PhpSyntax is FunctionCall fnc ? fnc.NameSpan : x.PhpSyntax.Span;
_diagnostics.Add(_routine, span.ToTextSpan(), ErrorCode.WRN_UndefinedFunctionCall, x.Name.NameValue.ToString());
}
}
}
Expand All @@ -363,7 +364,8 @@ private void CheckUndefinedMethodCall(BoundRoutineCall x, TypeSymbol type, Bound
{
if (name.IsDirect && x.TargetMethod.IsErrorMethodOrNull() && type != null && !type.IsErrorType())
{
_diagnostics.Add(_routine, ((FunctionCall)x.PhpSyntax).NameSpan.ToTextSpan(), ErrorCode.WRN_UndefinedMethodCall, name.NameValue.ToString(), type.Name);
var span = x.PhpSyntax is FunctionCall fnc ? fnc.NameSpan : x.PhpSyntax.Span;
_diagnostics.Add(_routine, span.ToTextSpan(), ErrorCode.WRN_UndefinedMethodCall, name.NameValue.ToString(), type.Name);
}
}

Expand Down

0 comments on commit fce134f

Please sign in to comment.