Fix PokemonExceptionCheck causes segfault on nested attributes
This commit is contained in:
parent
114f8880fb
commit
0acd33f48b
|
@ -40,17 +40,35 @@ class PokemonExceptionCheck : BaseAnalyzer
|
||||||
lc.accept(this);
|
lc.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ignoreType = true;
|
||||||
|
|
||||||
override void visit(const Catch c)
|
override void visit(const Catch c)
|
||||||
{
|
{
|
||||||
if (c.type.type2.symbol.identifierOrTemplateChain.identifiersOrTemplateInstances.length != 1)
|
ignoreType = false;
|
||||||
{
|
c.type.accept(this);
|
||||||
|
ignoreType = true;
|
||||||
|
|
||||||
c.accept(this);
|
c.accept(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override void visit(const Type2 type2)
|
||||||
|
{
|
||||||
|
if (ignoreType) return;
|
||||||
|
|
||||||
|
if (type2.type !is null)
|
||||||
|
{
|
||||||
|
type2.type.accept(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto identOrTemplate = c.type.type2.symbol.identifierOrTemplateChain.identifiersOrTemplateInstances[0];
|
|
||||||
|
if (type2.symbol.identifierOrTemplateChain.identifiersOrTemplateInstances.length != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto identOrTemplate = type2.symbol.identifierOrTemplateChain.identifiersOrTemplateInstances[0];
|
||||||
if (identOrTemplate.templateInstance !is null)
|
if (identOrTemplate.templateInstance !is null)
|
||||||
{
|
{
|
||||||
c.accept(this);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (identOrTemplate.identifier.text == "Throwable"
|
if (identOrTemplate.identifier.text == "Throwable"
|
||||||
|
@ -60,7 +78,6 @@ class PokemonExceptionCheck : BaseAnalyzer
|
||||||
immutable line = identOrTemplate.identifier.line;
|
immutable line = identOrTemplate.identifier.line;
|
||||||
addErrorMessage(line, column, message);
|
addErrorMessage(line, column, message);
|
||||||
}
|
}
|
||||||
c.accept(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +100,10 @@ unittest
|
||||||
catch (Exception err) // ok
|
catch (Exception err) // ok
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (shared(Exception) err) // ok
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Error err) // [warn]: Catching Error or Throwable is almost always a bad idea.
|
catch (Error err) // [warn]: Catching Error or Throwable is almost always a bad idea.
|
||||||
{
|
{
|
||||||
|
@ -91,9 +112,14 @@ unittest
|
||||||
catch (Throwable err) // [warn]: Catching Error or Throwable is almost always a bad idea.
|
catch (Throwable err) // [warn]: Catching Error or Throwable is almost always a bad idea.
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (shared(Error) err) // [warn]: Catching Error or Throwable is almost always a bad idea.
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
catch // [warn]: Catching Error or Throwable is almost always a bad idea.
|
catch // [warn]: Catching Error or Throwable is almost always a bad idea.
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}c, sac);
|
}c, sac);
|
||||||
|
|
Loading…
Reference in New Issue