mirror of
https://github.com/dlang-community/D-Scanner.git
synced 2025-04-30 07:10:06 +03:00
Fix range error in mismatched argument checker, disable logging from dsymbol
This commit is contained in:
parent
6dc1cb9191
commit
c09abbdab6
2 changed files with 55 additions and 52 deletions
2
makefile
2
makefile
|
@ -19,7 +19,7 @@ INCLUDE_PATHS = \
|
||||||
-Idsymbol/src -Icontainers/src
|
-Idsymbol/src -Icontainers/src
|
||||||
VERSIONS =
|
VERSIONS =
|
||||||
DEBUG_VERSIONS = -version=std_parser_verbose
|
DEBUG_VERSIONS = -version=std_parser_verbose
|
||||||
DMD_FLAGS = -w -O -inline -J. -od${OBJ_DIR}
|
DMD_FLAGS = -w -O -inline -J. -od${OBJ_DIR} -version=StdLoggerDisableWarning
|
||||||
DMD_TEST_FLAGS = -w -g -unittest -J.
|
DMD_TEST_FLAGS = -w -g -unittest -J.
|
||||||
|
|
||||||
all: dmdbuild
|
all: dmdbuild
|
||||||
|
|
|
@ -5,6 +5,7 @@ import dsymbol.scope_;
|
||||||
import dsymbol.symbol;
|
import dsymbol.symbol;
|
||||||
import std.d.ast;
|
import std.d.ast;
|
||||||
import std.d.lexer : tok;
|
import std.d.lexer : tok;
|
||||||
|
import dsymbol.builtin.names;
|
||||||
|
|
||||||
/// Checks for mismatched argument and parameter names
|
/// Checks for mismatched argument and parameter names
|
||||||
final class MismatchedArgumentCheck : BaseAnalyzer
|
final class MismatchedArgumentCheck : BaseAnalyzer
|
||||||
|
@ -30,7 +31,8 @@ final class MismatchedArgumentCheck : BaseAnalyzer
|
||||||
auto identVisitor = scoped!IdentVisitor;
|
auto identVisitor = scoped!IdentVisitor;
|
||||||
identVisitor.visit(fce.unaryExpression);
|
identVisitor.visit(fce.unaryExpression);
|
||||||
|
|
||||||
const(DSymbol)* sym = resolveSymbol(sc, identVisitor.names);
|
const(DSymbol)* sym = resolveSymbol(sc,
|
||||||
|
identVisitor.names.length > 0 ? identVisitor.names : [CONSTRUCTOR_SYMBOL_NAME]);
|
||||||
const istring[] params = sym is null ? [] : sym.opSlice().map!(a => cast() a.name).array();
|
const istring[] params = sym is null ? [] : sym.opSlice().map!(a => cast() a.name).array();
|
||||||
const ArgMismatch[] mismatches = compareArgsToParams(params, args);
|
const ArgMismatch[] mismatches = compareArgsToParams(params, args);
|
||||||
foreach (size_t i, ref const mm; mismatches)
|
foreach (size_t i, ref const mm; mismatches)
|
||||||
|
@ -124,7 +126,8 @@ const(DSymbol)* resolveSymbol(const Scope* sc, const istring[] symbolChain)
|
||||||
const(DSymbol)* sym = s[0];
|
const(DSymbol)* sym = s[0];
|
||||||
foreach (i; 1 .. symbolChain.length)
|
foreach (i; 1 .. symbolChain.length)
|
||||||
{
|
{
|
||||||
if (sym.kind == CompletionKind.variableName || sym.kind == CompletionKind.memberVariableName
|
if (sym.kind == CompletionKind.variableName
|
||||||
|
|| sym.kind == CompletionKind.memberVariableName
|
||||||
|| sym.kind == CompletionKind.functionName)
|
|| sym.kind == CompletionKind.functionName)
|
||||||
sym = sym.type;
|
sym = sym.type;
|
||||||
if (sym is null)
|
if (sym is null)
|
||||||
|
@ -164,8 +167,8 @@ string createWarningFromMismatch(const ArgMismatch mismatch) pure
|
||||||
{
|
{
|
||||||
import std.format : format;
|
import std.format : format;
|
||||||
|
|
||||||
return "Argument %d is named '%s', but this is the name of parameter %d"
|
return "Argument %d is named '%s', but this is the name of parameter %d".format(
|
||||||
.format(mismatch.argIndex + 1, mismatch.name, mismatch.paramIndex + 1);
|
mismatch.argIndex + 1, mismatch.name, mismatch.paramIndex + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue