Problem
is and test are reserved keywords in Home (used for type narrowing predicates and unit tests respectively), but the parser treats them as reserved everywhere — including the binding-name slot of let/var declarations, where there's no ambiguity:
var is: u32 = port_read32(port, PORT_IS) // ahci.home:384
let test: *VerificationTest = &tests[idx] // network_stack_verification.home:265
let test = &suite.tests[idx] // test/framework.home:194All produce error[EP0001]: Expected variable name.
Affected kernel files
- kernel/src/drivers/ahci.home:384 (
is) - kernel/src/drivers/storage/ahci.home:580 (
is) - kernel/src/test/framework.home:194 (
test) - kernel/src/net/network_stack_verification.home:265 (
test) - kernel/src/ml/autograd.home:605 (
test) - kernel/src/mm/user_space.home:278 (
test)
(Bucket 'Expected variable name', 6/66 of remaining kernel parse failures.)
Expected behavior
is and test should be contextual keywords: reserved only in their syntactic positions, parseable as plain identifiers everywhere else. Specifically:
isis a keyword only in pattern/type-narrowing position (e.g.if x is Foo { ... })testis a keyword only at top-level when followed by a string literal:test \"name\" { ... }
In all other contexts (let/var binding names, struct field names, parameter names, function names), they should parse as identifiers.
Implementation hint
Audit the lexer: confirm is / test are emitted as distinct token kinds (e.g. Tok.Is, Tok.Test). In parseLetDecl / parseVarDecl / parseFnParam / parseStructField, where the parser reads an identifier for the binding name, accept these two token kinds as identifiers. The cleanest fix is a small isIdentifierLikeToken helper.
Tests to add
var is: u32 = 0parseslet test = 1parsestest \"name\" { ... }still parses as a unit test (no regression)if x is Foo { ... }still parses as a type-narrow (no regression)
Acceptance
- The 6 listed kernel files clear
home-debug ast(parser side;ismay still need to typecheck against the local declared type). - No regressions on
if x is Tand top-leveltest \"...\"blocks. - Existing test suite green.