Disable runtime checks for production builds#28
Conversation
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdds a new array utility procedure to create/assign array elements with automatic expansion; introduces TGocciaValueList and TGocciaScopeList aliases and migrates many internal collections to use them; updates compiler directive conditional in Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Benchmark Results179 benchmarks · 🟢 5 improved · 174 unchanged · avg +1.9% arrays.js — 19 unchanged · avg -0.2%
classes.js — 15 unchanged · avg -0.4%
closures.js — 11 unchanged · avg -0.5%
collections.js — 12 unchanged · avg +0.5%
destructuring.js — 14 unchanged · avg +0.7%
fibonacci.js — 6 unchanged · avg +0.5%
iterators.js — 20 unchanged · avg +2.2%
json.js — 20 unchanged · avg +2.6%
jsx.jsx — 🟢 3 improved, 18 unchanged · avg +3.5%
numbers.js — 11 unchanged · avg +2.4%
objects.js — 🟢 1 improved, 6 unchanged · avg +4.1%
promises.js — 12 unchanged · avg +5.1%
strings.js — 🟢 1 improved, 10 unchanged · avg +5.6%
Measured on ubuntu-latest x64. Changes within ±7% are considered insignificant. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@units/Goccia.inc`:
- Around line 2-11: In Goccia.inc the {$ELSE} branch re-enables only
{$overflowchecks} and {$rangechecks} but leaves {$S}, {$OBJECTCHECKS} and {$C}
disabled; update the non-PRODUCTION branch to explicitly re-enable stack
checking and object checks and turn assertions back on by adding the
corresponding compiler directives (e.g. {$S+} or {$S ON}, {$OBJECTCHECKS ON} (or
{$OBJECTCHECKS+}), and {$C+}) in the {$ELSE} section so debug builds have the
intended stricter checking.
In `@units/Goccia.Utils.Array.pas`:
- Around line 7-25: Add a non-negative index check to ArrayCreateDataProperty to
guard against negative AIndex values: import Goccia.Values.ErrorHelper in the
uses clause and at the start of ArrayCreateDataProperty (procedure
ArrayCreateDataProperty(const AArray: TGocciaArrayValue; const AIndex: Integer;
const AValue: TGocciaValue)) validate that AIndex >= 0 and call
Goccia.Values.ErrorHelper.ThrowRangeError() when it is negative before
proceeding with AArray.Elements manipulation; this uses ThrowRangeError instead
of ERangeError per project guidelines.
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
units/Goccia.Values.FunctionBase.pas (1)
258-263:⚠️ Potential issue | 🟠 MajorMemory leak:
BoundArgsis never freed.
BoundArgsis created at line 258, its elements are copied into the newTGocciaBoundFunctionValueat line 275-279, but the originalBoundArgslist is never freed. The constructor creates its own copy, so the caller should free the original.🐛 Proposed fix to free BoundArgs
// Remaining arguments are pre-filled arguments BoundArgs := TGocciaValueList.Create(False); for I := 1 to AArgs.Length - 1 do BoundArgs.Add(AArgs.GetElement(I)); // Create and return a bound function Result := TGocciaBoundFunctionValue.Create(AThisValue, BoundThis, BoundArgs); + BoundArgs.Free; end;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@units/Goccia.Values.FunctionBase.pas` around lines 258 - 263, BoundArgs is allocated with TGocciaValueList.Create but never freed causing a memory leak; after constructing the bound function with TGocciaBoundFunctionValue.Create(AThisValue, BoundThis, BoundArgs) free the original BoundArgs (e.g., call BoundArgs.Free or FreeAndNil(BoundArgs)) since the constructor makes its own copy, ensuring you free BoundArgs in all paths (use try..finally if needed).
🧹 Nitpick comments (1)
units/Goccia.Evaluator.pas (1)
248-286: New helperSpreadIterableIntoArgsfor arguments collection.The new procedure duplicates
SpreadIterableIntologic but targetsTGocciaArgumentsCollectioninstead ofTGocciaValueList. While this creates code duplication, it's acceptable given the different target interfaces. Consider extracting the common iterator logic if more spread targets are added in the future.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@units/Goccia.Evaluator.pas` around lines 248 - 286, The new SpreadIterableIntoArgs duplicates the iterator/traversal logic present in SpreadIterableInto; refactor by extracting the common iteration behavior into a shared helper (e.g., IterateAndAddValues) that accepts an iterator and a callback to add each yielded value so both SpreadIterableInto and SpreadIterableIntoArgs call GetIteratorFromValue, use TGocciaGarbageCollector to AddTempRoot/RemoveTempRoot, advance via AdvanceNext and check PROP_DONE/PROP_VALUE, and invoke the callback to add into either TGocciaArgumentsCollection or TGocciaValueList; keep ThrowTypeError('Spread syntax requires an iterable') where iterator is nil.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@units/Goccia.Evaluator.pas`:
- Line 317: Remove the unused local variable Arguments: TGocciaValueList
declared in the EvaluateExpression routine; locate the EvaluateExpression
function and delete the Arguments declaration (and any related unused
references) so the function no longer contains the unused TGocciaValueList
variable.
In `@units/Goccia.Values.FunctionBase.pas`:
- Line 159: The declared but unused variable CallArgs of type TGocciaValueList
in the FunctionCall implementation should be removed; locate the CallArgs
declaration in the FunctionCall routine (symbol: CallArgs) and delete it so
there are no unused local variables left, and run the compiler to confirm no
remaining references to TGocciaValueList in that scope remain.
---
Outside diff comments:
In `@units/Goccia.Values.FunctionBase.pas`:
- Around line 258-263: BoundArgs is allocated with TGocciaValueList.Create but
never freed causing a memory leak; after constructing the bound function with
TGocciaBoundFunctionValue.Create(AThisValue, BoundThis, BoundArgs) free the
original BoundArgs (e.g., call BoundArgs.Free or FreeAndNil(BoundArgs)) since
the constructor makes its own copy, ensuring you free BoundArgs in all paths
(use try..finally if needed).
---
Nitpick comments:
In `@units/Goccia.Evaluator.pas`:
- Around line 248-286: The new SpreadIterableIntoArgs duplicates the
iterator/traversal logic present in SpreadIterableInto; refactor by extracting
the common iteration behavior into a shared helper (e.g., IterateAndAddValues)
that accepts an iterator and a callback to add each yielded value so both
SpreadIterableInto and SpreadIterableIntoArgs call GetIteratorFromValue, use
TGocciaGarbageCollector to AddTempRoot/RemoveTempRoot, advance via AdvanceNext
and check PROP_DONE/PROP_VALUE, and invoke the callback to add into either
TGocciaArgumentsCollection or TGocciaValueList; keep ThrowTypeError('Spread
syntax requires an iterable') where iterator is nil.
Summary by CodeRabbit
New Features
Chores / Refactor
Documentation
Tests