feat: selfhost-loop determinism, golden tests, sema diagnostics
This commit is contained in:
@@ -232,6 +232,8 @@ func Cli_Check(srcPath: String) -> int {
|
|||||||
while i < Sema_DiagCount(sema) {
|
while i < Sema_DiagCount(sema) {
|
||||||
Print(" line ");
|
Print(" line ");
|
||||||
PrintInt(sema.diags[i].line as int64);
|
PrintInt(sema.diags[i].line as int64);
|
||||||
|
Print(" col ");
|
||||||
|
PrintInt(sema.diags[i].column as int64);
|
||||||
Print(": ");
|
Print(": ");
|
||||||
PrintLine(sema.diags[i].message);
|
PrintLine(sema.diags[i].message);
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
@@ -656,6 +658,8 @@ func Cli_BuildProject(projectDir: String) -> int {
|
|||||||
while i < Sema_DiagCount(sema) {
|
while i < Sema_DiagCount(sema) {
|
||||||
Print(" line ");
|
Print(" line ");
|
||||||
PrintInt(sema.diags[i].line as int64);
|
PrintInt(sema.diags[i].line as int64);
|
||||||
|
Print(" col ");
|
||||||
|
PrintInt(sema.diags[i].column as int64);
|
||||||
Print(": ");
|
Print(": ");
|
||||||
PrintLine(sema.diags[i].message);
|
PrintLine(sema.diags[i].message);
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
|
|||||||
+6
-4
@@ -2,6 +2,9 @@
|
|||||||
// Validates types, resolves identifiers, checks function calls.
|
// Validates types, resolves identifiers, checks function calls.
|
||||||
module Sema {
|
module Sema {
|
||||||
|
|
||||||
|
extern func Print(s: String);
|
||||||
|
extern func PrintLine(s: String);
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Sema context
|
// Sema context
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -127,15 +130,14 @@ func Sema_TypeName(kind: int) -> String {
|
|||||||
|
|
||||||
func Sema_CheckBlock(sema: *Sema, block: *Block) {
|
func Sema_CheckBlock(sema: *Sema, block: *Block) {
|
||||||
if block == null as *Block { return; }
|
if block == null as *Block { return; }
|
||||||
var blockScope: Scope = Scope_NewChild(sema.scope);
|
// Use current scope directly — only function bodies create new scopes.
|
||||||
let prevScope: *Scope = sema.scope;
|
// This matches Nim bootstrap behavior and fixes variable visibility
|
||||||
sema.scope = &blockScope;
|
// in nested blocks (if/while bodies).
|
||||||
var stmt: *Stmt = block.firstStmt;
|
var stmt: *Stmt = block.firstStmt;
|
||||||
while stmt != null as *Stmt {
|
while stmt != null as *Stmt {
|
||||||
Sema_CheckStmt(sema, stmt);
|
Sema_CheckStmt(sema, stmt);
|
||||||
stmt = stmt.nextStmt;
|
stmt = stmt.nextStmt;
|
||||||
}
|
}
|
||||||
sema.scope = prevScope;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user