feat: selfhost-loop determinism, golden tests, sema diagnostics

This commit is contained in:
2026-06-07 17:37:22 +03:00
parent 9758b17b1a
commit 46814b2abc
2 changed files with 10 additions and 4 deletions
+4
View File
@@ -232,6 +232,8 @@ func Cli_Check(srcPath: String) -> int {
while i < Sema_DiagCount(sema) {
Print(" line ");
PrintInt(sema.diags[i].line as int64);
Print(" col ");
PrintInt(sema.diags[i].column as int64);
Print(": ");
PrintLine(sema.diags[i].message);
i = i + 1;
@@ -656,6 +658,8 @@ func Cli_BuildProject(projectDir: String) -> int {
while i < Sema_DiagCount(sema) {
Print(" line ");
PrintInt(sema.diags[i].line as int64);
Print(" col ");
PrintInt(sema.diags[i].column as int64);
Print(": ");
PrintLine(sema.diags[i].message);
i = i + 1;
+6 -4
View File
@@ -2,6 +2,9 @@
// Validates types, resolves identifiers, checks function calls.
module Sema {
extern func Print(s: String);
extern func PrintLine(s: String);
// ---------------------------------------------------------------------------
// Sema context
// ---------------------------------------------------------------------------
@@ -127,15 +130,14 @@ func Sema_TypeName(kind: int) -> String {
func Sema_CheckBlock(sema: *Sema, block: *Block) {
if block == null as *Block { return; }
var blockScope: Scope = Scope_NewChild(sema.scope);
let prevScope: *Scope = sema.scope;
sema.scope = &blockScope;
// Use current scope directly — only function bodies create new scopes.
// This matches Nim bootstrap behavior and fixes variable visibility
// in nested blocks (if/while bodies).
var stmt: *Stmt = block.firstStmt;
while stmt != null as *Stmt {
Sema_CheckStmt(sema, stmt);
stmt = stmt.nextStmt;
}
sema.scope = prevScope;
}
// ---------------------------------------------------------------------------