-
-
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
builtinfun.length undefined #210
Comments
I think I found the error. 'abc'.matchAll returns undefined and not the function object. |
If you create a string with (new String("abc")).matchAll.length returns the correct length. ExprDef::GetConstField(ref obj, ref field) => {
let mut obj = self.run(obj)?;
if obj.get_type() != "function"
&& (obj.get_type() != "object" || obj.get_type() != "symbol")
{
obj = self.to_object(&obj).expect("failed to convert to object");
}
Ok(obj.borrow().get_field_slice(field))
} If one of the maintainers provide me with a solution that should be used I can implement it. |
Is there now a good solution which should be used? |
Hey @Stupremee do you think this logic should be inside value.rs on |
I think so yes. |
I can take care of this issue. I will add the logic in |
I thought about this issue again, and I think it's the best method to create constant values (string, numbers) via the specific constructor. |
I think this particular case could be solved by function objects, in #255. |
I agree |
What is the state of this, @jasonwilliams ? |
In theory this is done, but i think there needs to be some checking and testing. It's already done for dynamic functions: for builtin functions, i think its just a case of going through and making sure they're all correct (i'm not sure if every single built-in needs a test for the correct length, that might be overkill, but maybe 1 or 2 tests for the builtins as well would be nice) In terms of So, outstanding on this is:
|
The original problem is solved but 'asd'['matchAll'].length isn't. There is a missmatch here: https://github.com/boa-dev/boa/blob/master/boa/src/exec/field/mod.rs#L10-L14 |
@jasonwilliams I intentionally didn't include this test, as it follows from the two tests that I did include.
Both of these were failing, and now both are fixed which I checked with tests, so their combination also works. |
Even if Nevertheless, note that the test that we want here is to check that the |
Well you can say also if x.y.z works no reason to belive x.y.z.w works. But the transitivity was not the problem in this issue.
How I understood it from the issue report and discussion is that this is not the issue. The built-in functions are just functions, so they have the same properties as other functions, and That string's built-in Now perhaps we can make an additional set of tests on the Function builtin where we assure that it has all the properties and methods a Function needs to have (like |
I think it's on the scope of the issue, from @jasonwilliams's comment:
|
I saw this. I don't agree that that is related to the issue as I explained above. But we can agree to disagree. |
Checking length is not out of scope of this issue. Your fix did allow us to access the built in methods of objects (thanks to boxing up the primitives) but it hasn’t added any checks for that, only that methods can be accessed on objects. |
This is incorrect. I checked that method I'm thinking now, perhaps builtin methods are not constructed from a function prototype but set its type function in different way, which would be a problem? |
Yep, builtins are created using Rust functions and added to objects. As an example: https://github.com/boa-dev/boa/blob/master/boa/src/builtins/bigint/mod.rs#L149-L165 |
I think this is fixed now, right? I can get the proper results using both methods. I'm closing this for now, and removing the milestone, since it seems it was solved at least on 0.9. |
I'm getting
undefined
when I do'abc'.matchAll.length
. This is incompatible with Chrome's implementation (for example), where I get1
.Testing with master with the following
tests.js
:Here's the output for
cargo run
:Related to #193 and #206
The text was updated successfully, but these errors were encountered: