-
Notifications
You must be signed in to change notification settings - Fork 148
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
the Function() method stub returns invalid value #41
Comments
Yes, the patch resolves the issue for Function(). The general problem is that return value of native function like njs_function_constructor() (NXT_ERROR, NXT_OK) is treated separately from the VM return value (vm->retval). njs shell uses njs_vm_value_dump() to dump vm->retval. njs_vm_init() sets vm->retval to undefined. So if a piece of code returns NXT_ERROR, but does not set vm->retval undefined
...
at main (native) will be printed |
Hi @xeioex! I'm mostly bothering about this: >> try { var a = Array(1111111111); } catch(e) { console.log(typeof e, e); }
'number' 1111111111
undefined |
Array constructor is expected to overwrite vm->retval with an exception value if an exception happens. Currently it does not do it (this is the main culprit). vm->retval is used everywhere inside the VM as an intermediate value. So, most of the time it stores the value of the previous instruction.
In the end the e argument of the catch block contains vm->retval value (which is the value of the last successful instruction (MOVE), which is 1111111111 number value) |
Thank you for an explanation, it's completely clear now! |
while the Function() constructor is a stub, it should throw InternalError, i think.
and there is problem around it and maybe in other places aswell
does this patch resolve the problem or just hide it?
The text was updated successfully, but these errors were encountered: