fix(selfhost): resolve all sema errors — 0 undeclared identifiers

- Add forward declarations for mutually-recursive parser functions
  (parserParseExpr, parserParseStmt, parserParseBlock,
   parserParsePrimary, parserParsePostfixExpr, parserParseBinaryPrec)
- Fix HIR lowering: skip forward decls (refBody==null) to avoid
  duplicate function entries and array overflow
- Bump funcs/externFuncs array size 256→512 to handle large modules
- Update PLAN.md with progress

Sema: 0 errors (was 7, then 2, now 0)
Remaining: C backend struct ordering (pre-existing, Iter/StringBuilder)
This commit is contained in:
2026-06-06 05:34:19 +03:00
parent a8b909726b
commit aff03ffb5a
2 changed files with 14 additions and 6 deletions
+10 -2
View File
@@ -4,6 +4,14 @@ module Parser {
extern func bux_strlen(s: String) -> uint;
// Forward declarations for mutual recursion
func parserParseExpr(p: *Parser) -> *Expr;
func parserParseStmt(p: *Parser) -> *Stmt;
func parserParseBlock(p: *Parser) -> *Block;
func parserParsePrimary(p: *Parser) -> *Expr;
func parserParsePostfixExpr(p: *Parser) -> *Expr;
func parserParseBinaryPrec(p: *Parser, minPrec: int) -> *Expr;
// ---------------------------------------------------------------------------
// Parser state
// ---------------------------------------------------------------------------
@@ -326,7 +334,7 @@ func parserParsePrimary(p: *Parser) -> *Expr {
// Postfix: call, index, field access, as, is, ?
// ---------------------------------------------------------------------------
func parserParsePostfix(p: *Parser) -> *Expr {
func parserParsePostfixExpr(p: *Parser) -> *Expr {
var left: *Expr = parserParsePrimary(p);
while true {
@@ -566,7 +574,7 @@ func parserPrecedence(op: int) -> int {
}
func parserParseBinaryPrec(p: *Parser, minPrec: int) -> *Expr {
var left: *Expr = parserParsePostfix(p);
var left: *Expr = parserParsePostfixExpr(p);
while true {
let op: int = parserPeek(p, 0);
let prec: int = parserPrecedence(op);