refactor: wrap plain scopes in Context.push()

Centralize null-prototype scope creation in push() so callers pass plain objects; Drop instances and existing null-proto frames are pushed as-is. Remove sanitizeScope in favor of createScope via Object.assign.
This commit is contained in:
Yang Jun
2026-07-19 23:42:09 +08:00
parent 812af67022
commit 90ab891c29
9 changed files with 37 additions and 30 deletions
+8 -2
View File
@@ -94,8 +94,14 @@ export class Context {
}
return scope
}
public push (ctx: object) {
return this.scopes.push(ctx)
public push (ctx: Scope): Scope {
const scope = ctx instanceof Drop
? ctx
: Object.getPrototypeOf(ctx) === null
? ctx
: createScope(ctx)
this.scopes.push(scope)
return scope
}
public pop () {
return this.scopes.pop()