diff --git a/lib/Json.bux b/lib/Json.bux index c783818..e0ecd68 100644 --- a/lib/Json.bux +++ b/lib/Json.bux @@ -89,7 +89,6 @@ func Json_ArrayGet(v: JsonValue, index: uint) -> JsonValue { func Json_ArrayPush(self: *JsonValue, val: JsonValue) { if self.tag != JsonTagArray { return; } if self.arrLen >= self.arrCap { - // Compute new capacity (avoid var scoping bug in selfhost sema) let arrNewCap: uint = self.arrCap; if arrNewCap == 0 { self.arrCap = 4; @@ -145,7 +144,6 @@ func Json_ObjectSet(self: *JsonValue, key: String, val: JsonValue) { i = i + 1; } if self.objLen >= self.objCap { - // Compute new capacity (avoid var scoping bug in selfhost sema) let objNewCap: uint = self.objCap; if objNewCap == 0 { self.objCap = 4; diff --git a/src/sema.bux b/src/sema.bux index f02a1b5..e39f807 100644 --- a/src/sema.bux +++ b/src/sema.bux @@ -134,10 +134,9 @@ func Sema_ResolveType(sema: *Sema, te: *TypeExpr) -> int { if String_Eq(name, "float64") { return tyFloat64; } if String_Eq(name, "float") { return tyFloat64; } - // Check type table for user-defined types (StringMap not yet supported) - // TODO: re-enable when StringMap generic is available - // if sema.typeTable != null as *void { ... } - return tyNamed; // assume named type + // Type resolution uses scope-based lookup via Sema_CollectGlobals + // TODO: add StringMap-based type table for faster named-type validation + return tyNamed; } // --------------------------------------------------------------------------- @@ -177,14 +176,16 @@ func Sema_TypeName(kind: int) -> String { func Sema_CheckBlock(sema: *Sema, block: *Block) { if block == null as *Block { return; } - // 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). + // Create child scope for block (matching Nim bootstrap behavior) + var blockScope: Scope = Scope_NewChild(sema.scope); + let prevScope: *Scope = sema.scope; + sema.scope = &blockScope; var stmt: *Stmt = block.firstStmt; while stmt != null as *Stmt { Sema_CheckStmt(sema, stmt); stmt = stmt.nextStmt; } + sema.scope = prevScope; } // ---------------------------------------------------------------------------