Add JavaScript S-expression execution engine#52
Conversation
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| "+" => Add(left, right), | ||
| "-" => ToNumber(left) - ToNumber(right), | ||
| "*" => ToNumber(left) * ToNumber(right), | ||
| "/" => ToNumber(right) == 0 ? throw new DivideByZeroException() : ToNumber(left) / ToNumber(right), |
There was a problem hiding this comment.
Bug: Floating-Point Zero-Check Fails Near-Zero Values
Division by zero check compares floating-point ToNumber(right) using exact equality with 0, which can fail due to floating-point precision issues. Values very close to zero but not exactly zero may incorrectly pass the check, while the division itself could still produce infinity or unexpected results.
| "+" => Add(left, right), | ||
| "-" => ToNumber(left) - ToNumber(right), | ||
| "*" => ToNumber(left) * ToNumber(right), | ||
| "/" => ToNumber(right) == 0 ? throw new DivideByZeroException() : ToNumber(left) / ToNumber(right), |
There was a problem hiding this comment.
Bug: Arithmetic division by zero throws exception instead of Infinity
Division by zero throws DivideByZeroException instead of returning Infinity like JavaScript. In JavaScript, dividing by zero produces Infinity or -Infinity, not an exception. This breaks JavaScript semantics and will cause runtime errors for valid JavaScript code like 1/0.
| SetPrototype(value); | ||
| } | ||
|
|
||
| this[name] = value; |
There was a problem hiding this comment.
Bug: Redundant Dictionary Update After SetPrototype Call
SetProperty always sets the dictionary entry on line 49 even after calling SetPrototype for __proto__. Since SetPrototype already updates the dictionary, this redundantly overwrites the same value. The method needs a return after line 46 or an else clause to avoid the redundant assignment.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_690d1332a964832893299aeb69ca57f3
Note
Introduces
Asynkron.JsEngineto parse JavaScript into S-expressions and evaluate with JS-like semantics, plus comprehensive tests and solution/docs wiring.src/Asynkron.JsEngine:Lexer,Parser-> S-expressions (Cons,Symbol,JsSymbols);Evaluatorwith lexicalEnvironmentand control signals.let/var/const), functions/closures, object/array literals (JsObject/JsArray), property/index ops,new, classes withextends/super, control flow (if/for/while/do-while/switch/try-catch-finally), logical/equality operators; host interop viaHostFunction; publicJsEnginefaçade.tests/Asynkron.JsEngine.Tests: xUnit coverage for parsing, evaluation, closures, interop, arrays/objects, classes/inheritance, control flow, operators.Asynkron.OTelMCP.sln; updatesrc/context.md; addAsynkron.JsEngine/context.mdand tests context.Written by Cursor Bugbot for commit 323088b. This will update automatically on new commits. Configure here.