fix(selfhost): block scoping for if/while/loop/match bodies
- Create child scope in Sema_CheckBlock for every block, matching bootstrap sema.nim behavior (newScope for ekBlock). - Fixes "var scoping bug in selfhost sema" where variables declared with var inside if/while blocks shared parent function scope, causing duplicate-definition errors between sibling if/else blocks, and C scoping mismatch between user variables and compiled output. - Remove stale workaround comments from lib/Json.bux (let instead of var inside if blocks — no longer needed). - Update sema.bux TODO comment for type table.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user