check .field access on structs #65
Loading…
Reference in a new issue
No description provided.
Delete branch "us55/field-access-on-structs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #55.
Type-checks
Expr::Field:basemust resolve to aTyKind::Struct, andnamemust be one of its declared fields; the access resolves to that field's declared type. ReportsTypeNotAStruct(Ty)when the base isn't a struct, andStructFieldNotDefined { name, field }when it is but the field doesn't exist — reusing the diagnostic already used bycheck_struct_literal.Filed #64 as a follow-up:
Expr::Field'snamehas no span (it's a bareIdent/Symbol), so both diagnostics currently point atbase's span rather than the field name itself.Test plan
cargo test -p twill-check(new unit tests for a valid field access, an unknown field, a non-struct base, and an undefined base var not double-reporting)