peggyjs / peggy

Peggy: Parser generator for JavaScript
https://peggyjs.org/
MIT License
883 stars 63 forks source link

Allow "constructor" and other object properties as grammar literals #521

Closed hildjj closed 3 weeks ago

hildjj commented 3 weeks ago

Fixes #520.

The Intern class uses an internal object to track whether a particular string has been seen before. It checks this with let num = this.offsets[s];. If one of the 8 base properties of Object is used as the literal name, num gets a non-numeric result.

The quick fix is to initialize offsets with an object that has no prototype instead of {}.

hildjj commented 3 weeks ago

Puppeteer tests are broken again. I'm going to take a few minutes to switch to playwright, and get the web tests running headless, cross-browser, and in CI.

Mingun commented 3 weeks ago

I did not test changes by myself, but they seems correct, so rely on CI.