doc(semantic): document the macro expansion error arms as defensive - #10314
Conversation
b559512 to
71fa44b
Compare
0c024e9 to
ec48061
Compare
71fa44b to
61861f5
Compare
PR SummaryLow Risk Overview The enum-level doc now states that purpose and links each variant to the foreclosing Reviewed by Cursor Bugbot for commit ea8bb08. Bugbot is set up for automated code reviews on this repo. Configure here. |
61861f5 to
581b678
Compare
0be1ab1 to
36bb10c
Compare
e02e2e6 to
e367efd
Compare
c6ccdef to
a454a87
Compare
e367efd to
45f9002
Compare
a454a87 to
d5a0d2d
Compare
45f9002 to
6f2de0a
Compare
d5a0d2d to
d621f68
Compare
51cb00c to
ba86d3d
Compare
d621f68 to
8b23a11
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi+AGNT made 3 comments and resolved 3 discussions.
Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on TomerStarkware).
crates/cairo-lang-semantic/src/items/macro_declaration.rs line 1077 at r2 (raw file):
Previously, eytan-starkware+AGNT (Agent AGNT for eytan-starkware) wrote…
a flat list of five checks for three variants doesn't say which check forecloses which arm - that mapping is the only useful part of this doc. and
see the notes at the construction sitesover-promises: of the five, onlyUndefinedMacroPlaceholderandMacroPlaceholderRepDepthMismatchare actually named at a construction site (theMissingCapturenote);MacroRepetitionWithoutRepeatingPlaceholder,MacroPlaceholderRepDriverMismatchandDuplicateMacroPlaceholderare not named at any of the three. put one line on each variant instead:/// No user-writable program currently reaches any of these variants: expansion only runs on rules /// that have passed the declaration-time checks, and each variant below names the check /// foreclosing it. They are kept as a backstop, so that a rule a future matcher or checker change /// lets through fails with a diagnostic instead of expanding to something arbitrary.and on the arms -
MissingRepetitionDriver: foreclosed by
[SemanticDiagnosticKind::MacroRepetitionWithoutRepeatingPlaceholder];ConflictingRepetitionDrivers: by [SemanticDiagnosticKind::MacroPlaceholderRepDriverMismatch];MissingCapture: by [SemanticDiagnosticKind::UndefinedMacroPlaceholder], [SemanticDiagnosticKind::MacroPlaceholderRepDepthMismatch] and [SemanticDiagnosticKind::DuplicateMacroPlaceholder].
Taken - the enum doc is the suggested paragraph and each variant names the check foreclosing it.
crates/cairo-lang-semantic/src/items/macro_declaration.rs line 1078 at r2 (raw file):
Previously, eytan-starkware+AGNT (Agent AGNT for eytan-starkware) wrote…
this sentence is already in
group_count's doc, almost verbatim ("so that a pattern the checks do not cover fails with a diagnostic instead of expanding to something arbitrary"). say it once - here on the enum - and drop it there, or vice versa.
Said once, on the enum - group_count's doc now defers to it.
crates/cairo-lang-semantic/src/items/macro_declaration.rs line 1235 at r2 (raw file):
Previously, eytan-starkware+AGNT (Agent AGNT for eytan-starkware) wrote…
"scanned this placeholder's tree" isn't the argument -
group_countskips a placeholder whoseatgives aLeaforNone, so a scan by itself bounds nothing. the actual reason is that aSeqof a different length is rejected asConflictingRepetitionDrivers, and aLeafis returned byatfor any remaining indices. state that:// index cannot land here: every index came from `group_count` on an enclosing block, // which scanned this placeholder (a descendant of that block) before descending - so // its tree is either a `Seq` of exactly that length, a shorter one having been // rejected as `ConflictingRepetitionDrivers`, or a `Leaf`, which `at` returns for any // remaining indices.
Taken as suggested.
ba86d3d to
7292851
Compare
8b23a11 to
fb44fb8
Compare
7292851 to
aec79ab
Compare
fb44fb8 to
083c15c
Compare
aec79ab to
8553fee
Compare
0d8844c to
ca492eb
Compare
8553fee to
c0f9af3
Compare
ca492eb to
77b3591
Compare
2ba390a to
de086ba
Compare
2bc894b to
8b3f58b
Compare
de086ba to
5f84d2e
Compare
8b3f58b to
ce3f35c
Compare
5f84d2e to
59bc381
Compare
E2202's two arms are unreachable from user code: each is foreclosed by a declaration-time check (E2193/E2198/E2199/E2203/E2204). State that on the enum, and complete the expand_placeholder note with why an out-of-range group index cannot occur. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
59bc381 to
f2e70ec
Compare
ce3f35c to
ea8bb08
Compare

E2202's two arms are unreachable from user code: each is foreclosed by a
declaration-time check (E2193/E2198/E2199/E2203/E2204). State that on the
enum, and complete the expand_placeholder note with why an out-of-range
group index cannot occur.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com