bellard / quickjs

Public repository of the QuickJS Javascript Engine.
https://bellard.org/quickjs
Other
8.54k stars 893 forks source link

Incorrect rejection of non-top-level `undefined` declarations #370

Open gibson042 opened 1 day ago

gibson042 commented 1 day ago

There are details at https://github.com/tc39/test262/issues/4332 , but the summary is that QuickJS incorrectly rejects as invalid attempts to create scoped declarations named undefined.

For example, this should print "START" and then "PASS", but instead throws a SyntaxError before anything happens (which is only warranted when such a declaration appears at the top-level scope):

print('START');
{
  const undefined = 1;
  print(undefined === 1 ? 'PASS' : 'FAIL');
}

It may also be worth noting that the analogous NaN and Infinity cases are handled correctly.

chqrlie commented 1 day ago

Hi @gibson042,

This is a bug and we shall fix it, but it is sad to see how many special cases need to be handled explicitly to emulate side effects of historical implementations in useless corner cases.

Thank you for this report.