-
-
Notifications
You must be signed in to change notification settings - Fork 34.8k
v8: add type check to make failed calls visible #1652
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Calling v8.setFlagsFromString with e.g a function as a flag argument gave no exception or warning that the function call will fail. There is now an exception if the function gets called with the wrong flag type (string is required) or that a flag is expected. Other APIs already provide exceptions if the argument has not the expected type.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,13 @@ void GetHeapStatistics(const FunctionCallbackInfo<Value>& args) { | |
|
|
||
|
|
||
| void SetFlagsFromString(const FunctionCallbackInfo<Value>& args) { | ||
| Environment* env = Environment::GetCurrent(args); | ||
|
|
||
| if (args.Length() < 1) | ||
| return env->ThrowTypeError("v8 flag is required"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that might be right, but
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, nevermind then. If the existing code uses |
||
| if (!args[0]->IsString()) | ||
| return env->ThrowTypeError("v8 flag must be a string"); | ||
|
|
||
| String::Utf8Value flags(args[0]); | ||
| V8::SetFlagsFromString(*flags, flags.length()); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| var common = require('../common'); | ||
| var assert = require('assert'); | ||
| var v8 = require('v8'); | ||
|
|
||
| assert.throws(function() {v8.setFlagsFromString(1)}, TypeError); | ||
| assert.throws(function() {v8.setFlagsFromString()}, TypeError); |
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.
Maybe make that
args.Length() < 1? Or simply drop it and rely on theargs[0]->IsString()check below to catch it.