Infinit recursion in subclass function.
recursive-beast opened this issue · 1 comments
I'm trying to get sql-bricks to work on an old environment, specifically Classic ASP using JScript as the scripting language ( javascript in es3 spec ).
everything is working fine when I'm using the standalone library, but when I'm using the mysql-bricks extension, I get an error indicating an "out of stack space" error.
After a day and a half of trying to fix the problem, I discovered that the problem is coming from the subclass function. The this
value inside cls
seems to cause the issue, If I try to print it every time cls
is called here's the result:
function cls() { if(this === Function("return this")()){ Response.Write("global object" + "
"); }else{ Response.Write(this + "
"); } if (!(this instanceof cls)) return applyNew(cls, arguments); base.apply(this, arguments); }global object
global object
... (Trancated)
global object
Microsoft JScript runtime error '800a001c'
Out of stack space
C:\USERS\RECURSIVE-BEAST\DESKTOP\REPOSITORIES\WHATS-APP\ROOT../backend/dist/bundle.js, line 1423
The first time, this
is cls
itself, then it's always the global object, which makes the condition !(this instanceof cls)
always true, because applyNew
gets called recursively, which in turn calls cls
with a this
value set to null
(global object).
I'm not sure why does this happen, maybe you could shed some light on this?
False alarm.
There are two versions of Function.prototype.bind
polyfills in the MDN website:
- The first one that doesn't support the
new
keyword, which is the one that's causingthis
to be the global object. - The second one supports it.
I was working with the first one.