boa: builtinfun.length undefined
I’m getting undefined when I do 'abc'.matchAll.length. This is incompatible with Chrome’s implementation (for example), where I get 1.
Testing with master with the following tests.js:
console.log('abc'.matchAll.length);
Here’s the output for cargo run:
$ cargo run
Compiling Boa v0.5.0 (/data/boa)
Finished dev [unoptimized + debuginfo] target(s) in 3.20s
Running `target/debug/boa`
undefined
[src/bin/bin.rs:57] exec(&buffer) = "undefined"
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 22 (22 by maintainers)
I think I found the error. The following code:
returns undefined and not the function object. Firefox console returns the function object instead. I will investigate further and try to find the cause
If you create a string with
"or', thebuiltins::string::create_constructor(aka String Constructor) is not used, and so the methods are not set. You can easily prove this, because this:returns the correct length. When a method is called from this string (this = the constant string “abc”), this string is first converted to an object by
Interpreter::to_object, thisto_objectmethod then uses the string prototype which has all methods set etc, so thematchAllmethod is also a property in the object. However, there is another problem. If the object you want to get a field from is a function, theto_objmethod returns an error. I’m not sure how best to fix the error. At the moment I can only offer the following Quick-Fix: Change this to this:If one of the maintainers provide me with a solution that should be used I can implement it.