Problem
The parser rejects /// doc-comments that appear between fields/methods inside a struct (or enum) body. Today this fails with error[EP0001]: Expected '}' after struct fields:
pub const SparseFile = struct {
inode: *homefs.Inode,
extent_tree: extents.ExtentTree,
block_size: u32,
pub fn init(...) SparseFile { ... }
/// Check if offset is in a hole ← parser bails here
pub fn is_hole(self: *SparseFile, offset: u64) !bool {
...
}
};The error column points at the /// itself, suggesting the inner-decl loop doesn't recognize doc-comments as a valid item.
Affected kernel files
- kernel/src/fs/sparse.home:91
- kernel/src/fs/largefile.home:156
- kernel/src/security/dm_verity.home:164
- kernel/src/security/keyring.home:189
- kernel/src/security/module_signing.home:159
(All are 'Expected } after struct fields' bucket — confirmed by spot-check on sparse.home.)
Expected behavior
Accept /// doc-comments anywhere a struct/enum-body item can appear:
- before the first field
- between fields
- before a method
- between methods
- before associated
pub const
Doc-comments don't need to attach to a particular AST node yet — silently consume them as the inner-decl loop iterates. (Future work: attach them to the next item for documentation generation.)
The same treatment should extend to enum bodies (already accepted methods after #52 — extend to doc-comments too).
Implementation hint
In the struct-body inner-decl loop (and the enum-body loop after #52), add a token check at the top: if the next token is Tok.DocComment (or whatever the lexer emits), consume it (and the line) as a no-op item, then continue. Likely a 5-line change.
Tests
- Positive snapshots: doc-comment before field, between fields, before method, before associated
const - Regression: existing struct/enum bodies parse identically
Acceptance
- The 5 listed kernel files clear
home-debug astpast the///line. - Existing test suite green.