Summary
The AST Field type carries no attribute storage, so field-level attributes are dropped during parsing. The concrete consequence is that #[indexed] on onchain enum event fields is lost, which will prevent correct EVM topic validation and event codegen once on-chain events are implemented.
Surfaced by Cubic review on PR #57 (compiler bootstrap), thread: #57 (comment). Deferred from that PR as out of scope for the lexer/parser bootstrap — this is a forward-looking gap, not a regression introduced by #57.
Current state (at 9a6f58d)
crates/sploosh-ast/src/lib.rs — Field { name, ty, visibility } has no attributes field. Field is shared by Struct, Actor fields, and VariantKind::Struct(Vec<Field>).
crates/sploosh-parser/src/lib.rs — attrs() only consumes @-style attributes (@test, @payable, …) via TokenKind::At. The #[...] attribute form is not attached to any AST node, even though the lexer does emit a Hash token.
- No corpus fixture under
tests/corpus/ exercises onchain enum events or #[indexed].
So #[indexed] is unsupported end-to-end today, not merely dropped on fields.
Spec reference
§11.5 — events allow up to 3 #[indexed] fields per variant on EVM (topics 1–3; topic 0 is the signature hash). More than 3 indexed fields on EVM is a compile error. SVM accepts #[indexed] as a no-op.
Scope / acceptance criteria
This should land together with general #[...] attribute parsing and on-chain event codegen in a later slice, where it can be verified end-to-end:
Notes
Not blocking — there is no on-chain event parsing or codegen yet. Track for the on-chain modules slice. Distinct from the open spec-debt in #54.
Summary
The AST
Fieldtype carries no attribute storage, so field-level attributes are dropped during parsing. The concrete consequence is that#[indexed]ononchain enumevent fields is lost, which will prevent correct EVM topic validation and event codegen once on-chain events are implemented.Surfaced by Cubic review on PR #57 (compiler bootstrap), thread: #57 (comment). Deferred from that PR as out of scope for the lexer/parser bootstrap — this is a forward-looking gap, not a regression introduced by #57.
Current state (at
9a6f58d)crates/sploosh-ast/src/lib.rs—Field { name, ty, visibility }has noattributesfield.Fieldis shared byStruct,Actorfields, andVariantKind::Struct(Vec<Field>).crates/sploosh-parser/src/lib.rs—attrs()only consumes@-style attributes (@test,@payable, …) viaTokenKind::At. The#[...]attribute form is not attached to any AST node, even though the lexer does emit aHashtoken.tests/corpus/exercisesonchain enumevents or#[indexed].So
#[indexed]is unsupported end-to-end today, not merely dropped on fields.Spec reference
§11.5 — events allow up to 3
#[indexed]fields per variant on EVM (topics 1–3; topic 0 is the signature hash). More than 3 indexed fields on EVM is a compile error. SVM accepts#[indexed]as a no-op.Scope / acceptance criteria
This should land together with general
#[...]attribute parsing and on-chain event codegen in a later slice, where it can be verified end-to-end:#[...]attributes and attach them to fields (extend the ASTField, or a dedicated event-field node, with attribute storage).#[indexed]through parsing ononchain enumevent-variant fields.#[indexed]as a no-op on SVM.Notes
Not blocking — there is no on-chain event parsing or codegen yet. Track for the on-chain modules slice. Distinct from the open spec-debt in #54.