-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate argument number checks for JS code #237
Conversation
b6e7e92
to
dab1ff2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done, thanks! But please address my comments.
* remove unnecessary whitespace change * change `handleFunction` to `setupFunction` and its parameter names * rename `JSBuilderSanityCheck` to `JSBuilderSanityChecks` and make it a trait which takes an `instrument: Bool` parameter and extends `JSBuilder` * use `TempSymbol` for vararg names * rename test file name to `SanityChecks.mls` and remove unnecessarily redefined sanity-checked function
Thanks for the comments! I have made the changes except for the one that makes sanity checks default, because currently several tests have function calls with incorrect number of arguments, but without Also previously I use |
Well, most are probably actual mistakes! Unless the intent was clearly to test what happens when the wrong number of arguments is passed, please just fix them by passing the correct number of arguments! |
* remove val for the `instrument` parameter * fix tests
Thanks for the comments! I have removed the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Just one last touch. And the errors would be more helpful if they had the following format:
Function 'foo' expected 3 arguments but got 2.
…e weird characters in name
I modified
JSBuilder.scala
such that now three places related to function/method codegen call the methodhandleFunction
to handle the common logic. ThehandleFunction
is overridden inJSBackendDiffMaker.scala
such that argument number sanity checks are implemented using varargs in javascript.I checked and also learned that in javascript
arguments.length
can also be used to determine how many arguments are actually passed into a function, but we generate arrow functions which do not havearguments
.