Operators Fix#1995
Conversation
(cherry picked from commit db806e4d2f35eb8560aeb1f33042d8ec8985ca3e)
There was a problem hiding this comment.
Code Review
This pull request introduces several utility updates and refactorings, including adding a callWithoutMetadata wrapper in operators.ts to simplify function calls, updating valueToStringDag to use this wrapper, and refactoring getChapterName in misc.ts to use direct enum indexing. Additionally, it updates mock import declarations to include an empty attributes array and adds tests for getVariantName. The review feedback suggests simplifying the type definition for ChapterStrings by using keyof typeof Chapter directly instead of introducing a redundant custom EnumKeys helper.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Coverage Report for CI Build 28381718839Coverage increased (+0.2%) to 78.717%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Akshay-2007-1
left a comment
There was a problem hiding this comment.
Hey, CI is failing on the format check, just a missing semicolon in rttc.test.ts:
}) // ← line 42, needs a semicolon
Just formatting issues.
I feel that the Gemini comment is valid although it isnt blocking and is just a trivial code improvement.
I think I wrote it the way I did because of some weird Typescript shennenigans not doing the type inference correctly, but as far as I can tell Typescript is behaving correctly, so not sure where that came from. |
… called correctly
|
Nice cleanup overall, the split into Stepper doesn't handle default params in arrow function arity check if (arrowFunction.params.length > this.arguments.length) {
throw new TooFewArgumentsError(this, this.arguments.length, arrowFunction.params.length, false);
}This counts all params including const f = (x, y = 0) => x + y;
f(1);will throw
defineBuiltin(context, 'display(val, prepend = undefined)', display, 2);
Null guard on if (!error.explain) {
console.error('Unhandled error', error);
}
const explanation = error.explain();If Debug log left as a comment in // console.log(f.name, f.length, maxArgsAllowed, receivedLength);This sits inside Stepper skips arity check for
|
|
Thanks @Akshay-2007-1.
|
Fix Module Functions not being called properly
With the way that functions need to be called in
js-slang, modules need access to thecallIfFuncAndRightArgsoperator, which is not properly being exported via therequireProviderright now.Fix Argument Count for Functions
Currently,
js-slangallows us to setminArgsNeededwhen the function takes in a variable number of parameters. But this is actually unnecessary since this is always inferrable fromf.length. Instead, what is unknown is the maximum number of arguments:wraphas been updated to take the number of optional parameters instead of the minimum number of arguments. Iftrueis passed in instead, then the function is assumed to have a rest parameter and thus no argument maximum.Functions should declare all required parameters in their signature.
With this, errors will now be thrown if a function is called with more arguments than is allowed.
I lied
It turns out certain functions likeMath.maxandMath.minhave length of 2 but take any number of parameters because reasons. Easy workarounds like just wrapping both those functions in an arrow function.Variable numbers of arguments for modules
If a bundle's function is defined using
wrap, then it will now be able to take in default parameters and rest parameters, fixing #1238.