Skip to content

Commit

Permalink
eof: Add yul syntax test and proper error for too many subcontainers
Browse files Browse the repository at this point in the history
  • Loading branch information
rodiazet committed Nov 29, 2024
1 parent 216b9eb commit 52781f0
Show file tree
Hide file tree
Showing 2 changed files with 293 additions and 9 deletions.
32 changes: 23 additions & 9 deletions libyul/AsmAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,13 +800,27 @@ bool AsmAnalyzer::validateInstructions(FunctionCall const& _functionCall)

void AsmAnalyzer::validateObjectStructure(langutil::SourceLocation _astRootLocation)
{
if (m_eofVersion.has_value() && util::contains(m_objectStructure.objectName, '.')) // No dots in object name for EOF
m_errorReporter.syntaxError(
9822_error,
_astRootLocation,
fmt::format(
"The object name \"{objectName}\" is invalid in EOF context. Object names must not contain 'dot' character.",
fmt::arg("objectName", m_objectStructure.objectName)
)
);
if (m_eofVersion.has_value())
{
if (util::contains(m_objectStructure.objectName, '.')) // No dots in object name for EOF
m_errorReporter.syntaxError(
9822_error,
_astRootLocation,
fmt::format(
"The object name \"{objectName}\" is invalid in EOF context. Object names must not contain 'dot' character.",
fmt::arg("objectName", m_objectStructure.objectName)
)
);
else if (m_objectStructure.topLevelSubObjectNames().size() > 256)
{
m_errorReporter.syntaxError(
1305_error,
_astRootLocation,
fmt::format(
"Too many subobjects in \"{objectName}\". At most 256 subobjects allowed when compiling to EOF",
fmt::arg("objectName", m_objectStructure.objectName)
)
);
}
}
}
270 changes: 270 additions & 0 deletions test/libyul/yulSyntaxTests/eof/too_many_subcontainers.yul
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
object "a" {
code {
mstore(0, eofcreate("s0000", 0, 0, 0, 0))
return(0, 32)
}

object "s0000" {code{}}
object "s0001" {code{}}
object "s0002" {code{}}
object "s0003" {code{}}
object "s0004" {code{}}
object "s0005" {code{}}
object "s0006" {code{}}
object "s0007" {code{}}
object "s0008" {code{}}
object "s0009" {code{}}
object "s0010" {code{}}
object "s0011" {code{}}
object "s0012" {code{}}
object "s0013" {code{}}
object "s0014" {code{}}
object "s0015" {code{}}
object "s0016" {code{}}
object "s0017" {code{}}
object "s0018" {code{}}
object "s0019" {code{}}
object "s0020" {code{}}
object "s0021" {code{}}
object "s0022" {code{}}
object "s0023" {code{}}
object "s0024" {code{}}
object "s0025" {code{}}
object "s0026" {code{}}
object "s0027" {code{}}
object "s0028" {code{}}
object "s0029" {code{}}
object "s0030" {code{}}
object "s0031" {code{}}
object "s0032" {code{}}
object "s0033" {code{}}
object "s0034" {code{}}
object "s0035" {code{}}
object "s0036" {code{}}
object "s0037" {code{}}
object "s0038" {code{}}
object "s0039" {code{}}
object "s0040" {code{}}
object "s0041" {code{}}
object "s0042" {code{}}
object "s0043" {code{}}
object "s0044" {code{}}
object "s0045" {code{}}
object "s0046" {code{}}
object "s0047" {code{}}
object "s0048" {code{}}
object "s0049" {code{}}
object "s0050" {code{}}
object "s0051" {code{}}
object "s0052" {code{}}
object "s0053" {code{}}
object "s0054" {code{}}
object "s0055" {code{}}
object "s0056" {code{}}
object "s0057" {code{}}
object "s0058" {code{}}
object "s0059" {code{}}
object "s0060" {code{}}
object "s0061" {code{}}
object "s0062" {code{}}
object "s0063" {code{}}
object "s0064" {code{}}
object "s0065" {code{}}
object "s0066" {code{}}
object "s0067" {code{}}
object "s0068" {code{}}
object "s0069" {code{}}
object "s0070" {code{}}
object "s0071" {code{}}
object "s0072" {code{}}
object "s0073" {code{}}
object "s0074" {code{}}
object "s0075" {code{}}
object "s0076" {code{}}
object "s0077" {code{}}
object "s0078" {code{}}
object "s0079" {code{}}
object "s0080" {code{}}
object "s0081" {code{}}
object "s0082" {code{}}
object "s0083" {code{}}
object "s0084" {code{}}
object "s0085" {code{}}
object "s0086" {code{}}
object "s0087" {code{}}
object "s0088" {code{}}
object "s0089" {code{}}
object "s0090" {code{}}
object "s0091" {code{}}
object "s0092" {code{}}
object "s0093" {code{}}
object "s0094" {code{}}
object "s0095" {code{}}
object "s0096" {code{}}
object "s0097" {code{}}
object "s0098" {code{}}
object "s0099" {code{}}
object "s0100" {code{}}
object "s0101" {code{}}
object "s0102" {code{}}
object "s0103" {code{}}
object "s0104" {code{}}
object "s0105" {code{}}
object "s0106" {code{}}
object "s0107" {code{}}
object "s0108" {code{}}
object "s0109" {code{}}
object "s0110" {code{}}
object "s0111" {code{}}
object "s0112" {code{}}
object "s0113" {code{}}
object "s0114" {code{}}
object "s0115" {code{}}
object "s0116" {code{}}
object "s0117" {code{}}
object "s0118" {code{}}
object "s0119" {code{}}
object "s0120" {code{}}
object "s0121" {code{}}
object "s0122" {code{}}
object "s0123" {code{}}
object "s0124" {code{}}
object "s0125" {code{}}
object "s0126" {code{}}
object "s0127" {code{}}
object "s0128" {code{}}
object "s0129" {code{}}
object "s0130" {code{}}
object "s0131" {code{}}
object "s0132" {code{}}
object "s0133" {code{}}
object "s0134" {code{}}
object "s0135" {code{}}
object "s0136" {code{}}
object "s0137" {code{}}
object "s0138" {code{}}
object "s0139" {code{}}
object "s0140" {code{}}
object "s0141" {code{}}
object "s0142" {code{}}
object "s0143" {code{}}
object "s0144" {code{}}
object "s0145" {code{}}
object "s0146" {code{}}
object "s0147" {code{}}
object "s0148" {code{}}
object "s0149" {code{}}
object "s0150" {code{}}
object "s0151" {code{}}
object "s0152" {code{}}
object "s0153" {code{}}
object "s0154" {code{}}
object "s0155" {code{}}
object "s0156" {code{}}
object "s0157" {code{}}
object "s0158" {code{}}
object "s0159" {code{}}
object "s0160" {code{}}
object "s0161" {code{}}
object "s0162" {code{}}
object "s0163" {code{}}
object "s0164" {code{}}
object "s0165" {code{}}
object "s0166" {code{}}
object "s0167" {code{}}
object "s0168" {code{}}
object "s0169" {code{}}
object "s0170" {code{}}
object "s0171" {code{}}
object "s0172" {code{}}
object "s0173" {code{}}
object "s0174" {code{}}
object "s0175" {code{}}
object "s0176" {code{}}
object "s0177" {code{}}
object "s0178" {code{}}
object "s0179" {code{}}
object "s0180" {code{}}
object "s0181" {code{}}
object "s0182" {code{}}
object "s0183" {code{}}
object "s0184" {code{}}
object "s0185" {code{}}
object "s0186" {code{}}
object "s0187" {code{}}
object "s0188" {code{}}
object "s0189" {code{}}
object "s0190" {code{}}
object "s0191" {code{}}
object "s0192" {code{}}
object "s0193" {code{}}
object "s0194" {code{}}
object "s0195" {code{}}
object "s0196" {code{}}
object "s0197" {code{}}
object "s0198" {code{}}
object "s0199" {code{}}
object "s0200" {code{}}
object "s0201" {code{}}
object "s0202" {code{}}
object "s0203" {code{}}
object "s0204" {code{}}
object "s0205" {code{}}
object "s0206" {code{}}
object "s0207" {code{}}
object "s0208" {code{}}
object "s0209" {code{}}
object "s0210" {code{}}
object "s0211" {code{}}
object "s0212" {code{}}
object "s0213" {code{}}
object "s0214" {code{}}
object "s0215" {code{}}
object "s0216" {code{}}
object "s0217" {code{}}
object "s0218" {code{}}
object "s0219" {code{}}
object "s0220" {code{}}
object "s0221" {code{}}
object "s0222" {code{}}
object "s0223" {code{}}
object "s0224" {code{}}
object "s0225" {code{}}
object "s0226" {code{}}
object "s0227" {code{}}
object "s0228" {code{}}
object "s0229" {code{}}
object "s0230" {code{}}
object "s0231" {code{}}
object "s0232" {code{}}
object "s0233" {code{}}
object "s0234" {code{}}
object "s0235" {code{}}
object "s0236" {code{}}
object "s0237" {code{}}
object "s0238" {code{}}
object "s0239" {code{}}
object "s0240" {code{}}
object "s0241" {code{}}
object "s0242" {code{}}
object "s0243" {code{}}
object "s0244" {code{}}
object "s0245" {code{}}
object "s0246" {code{}}
object "s0247" {code{}}
object "s0248" {code{}}
object "s0249" {code{}}
object "s0250" {code{}}
object "s0251" {code{}}
object "s0252" {code{}}
object "s0253" {code{}}
object "s0254" {code{}}
object "s0255" {code{}}
object "s0256" {code{}}
}

// ====
// EVMVersion: >=prague
// bytecodeFormat: >=EOFv1
// ----
// SyntaxError 1305: (22-101): Too many subobjects in "a". At most 256 subobjects allowed when compiling to EOF

0 comments on commit 52781f0

Please sign in to comment.