Field-name spans: Expr::Field.name has no span #64

Open
opened 2026-09-16 19:11:53 +00:00 by jacksonopp · 0 comments
Owner

Found while implementing #55 (check .field access on structs).

`Expr::Field { base: BoxSpannedExpr, name: Ident<'src> }` in `twill-parser/src/ast.rs` — `Ident<'src>` is just `&'src str`, with no span attached. This carries through the lowering pass into the checker's HIR, where `name` becomes a bare `Symbol<'db>`, also spanless.

Effect: `check_field`'s `StructFieldNotDefined` diagnostic (and any future field-access diagnostic) can only point at `base`'s span (`foo` in `foo.bar`), not at the field name itself (`bar`) — even though the field name is the actual source of the error.

Fix would be parser-level: `Field { name: Ident<'src> }` needs to become something like `Field { name: Spanned<Ident<'src>> }` (or a small spanned-ident wrapper), threaded through lowering into HIR's `Symbol` too.

Found while implementing #55 (check .field access on structs). \`Expr::Field { base: BoxSpannedExpr, name: Ident<'src> }\` in \`twill-parser/src/ast.rs\` — \`Ident<'src>\` is just \`&'src str\`, with no span attached. This carries through the lowering pass into the checker's HIR, where \`name\` becomes a bare \`Symbol<'db>\`, also spanless. Effect: \`check_field\`'s \`StructFieldNotDefined\` diagnostic (and any future field-access diagnostic) can only point at \`base\`'s span (\`foo\` in \`foo.bar\`), not at the field name itself (\`bar\`) — even though the field name is the actual source of the error. Fix would be parser-level: \`Field { name: Ident<'src> }\` needs to become something like \`Field { name: Spanned<Ident<'src>> }\` (or a small spanned-ident wrapper), threaded through lowering into HIR's \`Symbol\` too.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jacksonopp/twill#64
No description provided.