Skip to content

Conversation

@sileix
Copy link

@sileix sileix commented Jun 29, 2021

Objects created from literal syntax will inherit properties from
Object.prototype, which includes constructor.
As a result, lexcon['constructor'] will return a function object
instead of undefined.

This bug was discovered while using en-pos, and can be reproduced by the following code:

const Tag = require("en-pos").Tag;
const tags = new Tag(["constructor"]).initial() .smooth().tags;

During initial(), it calls lexicon.ts where it assumes the return value of lexicon[token] is either undefined or string.

Object created from literal syntax will inherit properties from
`Object.prototype`, which includes `constructor`.
As a result, `lexcon['constructor']` will return a function object
instead of undefined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant