mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix printing source for missing pragma.
This commit is contained in:
parent
e8eb1f2d14
commit
b3b8441aa4
@ -46,7 +46,7 @@ SourceReference SourceReferenceExtractor::extract(SourceLocation const* _locatio
|
||||
if (!_location || !_location->source.get()) // Nothing we can extract here
|
||||
return SourceReference::MessageOnly(std::move(message));
|
||||
|
||||
if (_location->source->source().empty()) // No source text, so we can only extract the source name
|
||||
if (!_location->hasText()) // No source text, so we can only extract the source name
|
||||
return SourceReference::MessageOnly(std::move(message), _location->source->name());
|
||||
|
||||
shared_ptr<CharStream> const& source = _location->source;
|
||||
|
@ -69,6 +69,8 @@ void SourceReferenceFormatter::printSourceName(SourceReference const& _ref)
|
||||
{
|
||||
if (_ref.position.line != -1)
|
||||
m_stream << _ref.sourceName << ":" << (_ref.position.line + 1) << ":" << (_ref.position.column + 1) << ": ";
|
||||
else if (!_ref.sourceName.empty())
|
||||
m_stream << _ref.sourceName << ": ";
|
||||
}
|
||||
|
||||
void SourceReferenceFormatter::printExceptionInformation(util::Exception const& _exception, std::string const& _category)
|
||||
|
@ -67,13 +67,20 @@ AnsiColorized SourceReferenceFormatterHuman::diagColored() const
|
||||
|
||||
void SourceReferenceFormatterHuman::printSourceLocation(SourceReference const& _ref)
|
||||
{
|
||||
if (_ref.position.line < 0)
|
||||
if (_ref.sourceName.empty())
|
||||
return; // Nothing we can print here
|
||||
|
||||
int const leftpad = static_cast<int>(log10(max(_ref.position.line, 1))) + 1;
|
||||
|
||||
// line 0: source name
|
||||
frameColored() << string(leftpad, ' ') << "--> ";
|
||||
|
||||
if (_ref.position.line < 0)
|
||||
{
|
||||
m_stream << _ref.sourceName << "\n";
|
||||
return; // No line available, nothing else to print
|
||||
}
|
||||
|
||||
m_stream << _ref.sourceName << ":" << (_ref.position.line + 1) << ":" << (_ref.position.column + 1) << ":" << '\n';
|
||||
|
||||
if (!_ref.multiline)
|
||||
|
@ -68,7 +68,8 @@ void SyntaxChecker::endVisit(SourceUnit const& _sourceUnit)
|
||||
to_string(recommendedVersion.patch()) +
|
||||
string(";\"");
|
||||
|
||||
m_errorReporter.warning(_sourceUnit.location(), errorString);
|
||||
// when reporting the warning, print the source name only
|
||||
m_errorReporter.warning({-1, -1, _sourceUnit.location().source}, errorString);
|
||||
}
|
||||
m_sourceUnit = nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user