Enforce private static brand checks#168
Conversation
- Reject inherited `this.#name` reads and writes on static private members - Add bytecode support for declared private static names - Cover the behavior with class tests and tutorial docs
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis pull request implements "brand" checking for private static fields across the GocciaScript runtime. Subclass receivers are now rejected when accessing or mutating base class private static state, enforced through compiler opcodes, evaluator validation, and VM execution handlers. Changes
Sequence DiagramsequenceDiagram
participant Compiler
participant VM as VM/Runtime
participant Evaluator
participant ClassValue
Compiler->>VM: Emit OP_CLASS_DECLARE_PRIVATE_STATIC_CONST<br/>(class, name, 0)
VM->>ClassValue: Add private static property<br/>with name as key
Note over Evaluator,ClassValue: Later: Read/Write Operation
Evaluator->>ClassValue: Query HasOwnPrivateStaticName(key)
ClassValue-->>Evaluator: Name exists in class
alt Brand Check Success
Evaluator->>ClassValue: Read/Write to private static
ClassValue-->>Evaluator: Value returned/set
else Brand Check Failure
Evaluator->>Evaluator: EnsurePrivateStaticBrand fails
Evaluator-->>VM: Throw TypeError
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly Related Issues
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Fixes #150 |
Benchmark Results263 benchmarks Interpreted: 🟢 246 improved · 🔴 4 regressed · 13 unchanged · avg +7.7% arraybuffer.js — Interp: 🟢 10, 4 unch. · avg +6.3% · Bytecode: 🟢 4, 🔴 4, 6 unch. · avg -0.2%
arrays.js — Interp: 🟢 17, 2 unch. · avg +5.7% · Bytecode: 🟢 10, 🔴 1, 8 unch. · avg +4.3%
async-await.js — Interp: 🟢 5, 1 unch. · avg +5.2% · Bytecode: 🟢 1, 🔴 1, 4 unch. · avg -0.1%
classes.js — Interp: 🟢 31 · avg +7.0% · Bytecode: 🟢 10, 21 unch. · avg +2.0%
closures.js — Interp: 🟢 11 · avg +8.6% · Bytecode: 🟢 7, 🔴 1, 3 unch. · avg +3.5%
collections.js — Interp: 🟢 6, 🔴 3, 3 unch. · avg +3.8% · Bytecode: 🟢 2, 🔴 8, 2 unch. · avg -5.3%
destructuring.js — Interp: 🟢 22 · avg +8.4% · Bytecode: 🟢 5, 🔴 4, 13 unch. · avg +0.4%
fibonacci.js — Interp: 🟢 8 · avg +9.9% · Bytecode: 🟢 1, 🔴 5, 2 unch. · avg -1.9%
for-of.js — Interp: 🟢 6, 1 unch. · avg +6.9% · Bytecode: 🟢 1, 🔴 2, 4 unch. · avg +0.2%
helpers/bench-module.js — Interp: 0 · Bytecode: 0
iterators.js — Interp: 🟢 20 · avg +10.5% · Bytecode: 🟢 5, 🔴 5, 10 unch. · avg +0.3%
json.js — Interp: 🟢 20 · avg +7.5% · Bytecode: 🔴 7, 13 unch. · avg -1.5%
jsx.jsx — Interp: 🟢 21 · avg +8.3% · Bytecode: 🔴 10, 11 unch. · avg -1.5%
modules.js — Interp: 🟢 8, 🔴 1 · avg +5.3% · Bytecode: 🟢 1, 🔴 6, 2 unch. · avg -1.5%
numbers.js — Interp: 🟢 11 · avg +9.7% · Bytecode: 🟢 3, 🔴 6, 2 unch. · avg +1.5%
objects.js — Interp: 🟢 7 · avg +11.1% · Bytecode: 🟢 1, 🔴 3, 3 unch. · avg -0.7%
promises.js — Interp: 🟢 12 · avg +7.2% · Bytecode: 🔴 3, 9 unch. · avg -0.3%
strings.js — Interp: 🟢 10, 1 unch. · avg +7.6% · Bytecode: 🔴 10, 1 unch. · avg -4.4%
typed-arrays.js — Interp: 🟢 21, 1 unch. · avg +9.1% · Bytecode: 🟢 3, 🔴 8, 11 unch. · avg -0.6%
Measured on ubuntu-latest x64. Benchmark ranges compare cached main-branch min/max ops/sec with the PR run; overlapping ranges are treated as unchanged noise. Percentage deltas are secondary context. |
Suite Timing
Measured on ubuntu-latest x64. |
Summary
this.TypeError.Testing
tests/language/classes/private-static-fields.jsfor subclass receiver reads, writes, and accessor writes../build.pas testrunner && ./build/TestRunner tests.Summary by CodeRabbit
Release Notes
Documentation
Tests
Bug Fixes