Skip to content

Commit b7edcc5

Browse files
authored
Merge pull request #11646 from ethereum/doNotUseCurrentSourceForMinusOne
Use unknown file for invalid source index.
2 parents dda362f + e5ab68e commit b7edcc5

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

libyul/AsmParser.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,8 @@ void Parser::fetchSourceLocationFromComment()
131131
m_debugDataOverride = DebugData::create();
132132
if (!sourceIndex || !start || !end)
133133
m_errorReporter.syntaxError(6367_error, commentLocation, "Invalid value in source location mapping. Could not parse location specification.");
134-
else if (!((*start < 0 && *end < 0) || (*start >= 0 && *start <= *end)))
135-
m_errorReporter.syntaxError(5798_error, commentLocation, "Invalid value in source location mapping. Start offset larger than end offset.");
136-
else if (sourceIndex == -1 && (0 <= *start && *start <= *end)) // Use source index -1 to indicate original source.
137-
m_debugDataOverride = DebugData::create(SourceLocation{*start, *end, ParserBase::currentLocation().source});
134+
else if (sourceIndex == -1)
135+
m_debugDataOverride = DebugData::create(SourceLocation{*start, *end, nullptr});
138136
else if (!(sourceIndex >= 0 && m_charStreamMap->count(static_cast<unsigned>(*sourceIndex))))
139137
m_errorReporter.syntaxError(2674_error, commentLocation, "Invalid source mapping. Source index not defined via @use-src.");
140138
else

test/libyul/Parser.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,7 @@ BOOST_AUTO_TEST_CASE(customSourceLocations_reference_original_sloc)
573573
BOOST_REQUIRE(holds_alternative<VariableDeclaration>(result->statements.at(0)));
574574
VariableDeclaration const& varDecl = get<VariableDeclaration>(result->statements.at(0));
575575

576-
// -1 points to original source code, which in this case is `sourceText` (which is also
577-
// available via `0`, that's why the first @src is set to `1` instead.)
578-
CHECK_LOCATION(varDecl.debugData->location, sourceText, 10, 20);
576+
CHECK_LOCATION(varDecl.debugData->location, "", 10, 20);
579577
}
580578

581579
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)