-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Implement Display for function objects #1309
Implement Display for function objects #1309
Conversation
96f13dd
to
ba2ba44
Compare
Test262 conformance changes:
Fixed tests:
|
aff5716
to
14b381a
Compare
Fixed 2 of the 4 broken tests. Ran Both pass locally in strict and non strict mode but it seems like 2 tests are broken somewhere else and I can't find them
Resolved |
|
boa/src/builtins/function/mod.rs
Outdated
@@ -329,6 +329,79 @@ impl BuiltInFunctionObject { | |||
// TODO?: 5. PrepareForTailCall | |||
context.call(this, &this_arg, &arg_list) | |||
} | |||
|
|||
fn to_string(this: &Value, _: &[Value], context: &mut Context) -> Result<Value> { |
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.
You seem to not be using the this
variable here, and it's causing a clippy
error. You can change it to _this
to avoid it.
I updated the conformance. This is generated in the CI and we have to manually copy it here (until we find a better solution) |
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.
Phrasing suggestion, overall looks ok.
Includes some fixes for new type names
This Pull Request fixes/closes #361.
Hello!
This is my first attempt at a contribution here let me know if I'm being dumb. I decided to go ahead and stick the most naive implementation I could think of as a beginning of a discussion while I get to grips with the codebase. I also have questions.
Thanks!
It changes the following:
Value::to_string
that handles function objects (for now)Questions:
Do all function values have a name? Right now I'm operating on the assumption that
get_field("name")
can totally fail and if it does, we proceed without a name.How much of the naive code in the implementation do you think should go into
impl Display for Function
?Value
that contains it, not the function itself, i was thinking of exposing something likedisplay_function_body
instead or something.How do I get at the actual backing source code that generated something? Testing this out in the browser It seems like the console.log implementation sticks the actual defined source code in there including formatting (newlines, spaces, etc).
Why do
const x = () => {}
functions not have names?Is there a way to get at the backing
Declr
for any of the function objects? It seems like that's the only place where arrow, expression, and function definitions are differentiated.Tested with
Outputs