acornjs / acorn-private-class-elements Goto Github PK
View Code? Open in Web Editor NEWHelpers for supporting private class methods and fields in acorn
License: MIT License
Helpers for supporting private class methods and fields in acorn
License: MIT License
Hi, node recently added a --disable-proto
option to disable use of __proto__
due to security issues: nodejs/node#32279. Similarly, deno also recently removed support for __proto__
: denoland/deno#4341. Would you consider removing the use of __proto__
in this package? The changes proposed in #10 would take care of it if merged.
Due to an invalid semver check, this entire library fails in Acorn 7+.
TEST.js:
'use strict';
Error.stackTraceLimit = 100;
const Parser = require('acorn').Parser.extend(require('acorn-class-fields'));
Parser.parse('a.#1=c;');
The error thrown is not friendly with loc
info any more:
if (!this._privateBoundNamesStack.length || !this._privateBoundNamesStack[this._privateBoundNamesStack.length - 1][node.property.name]) {
^
TypeError: Cannot read property 'length' of undefined
at Object.parseSubscript (/node_modules/acorn-class-fields/node_modules/acorn-private-class-elements/index.js:101:43)
at Object.pp$3.parseSubscripts (/node_modules/acorn/dist/acorn.js:2104:26)
at Object.pp$3.parseExprSubscripts (/node_modules/acorn/dist/acorn.js:2092:23)
at Object.pp$3.parseMaybeUnary (/node_modules/acorn/dist/acorn.js:2066:19)
at Object.parseMaybeUnary (/node_modules/acorn-class-fields/node_modules/acorn-private-class-elements/index.js:112:29)
at Object.pp$3.parseExprOps (/node_modules/acorn/dist/acorn.js:2010:21)
at Object.pp$3.parseMaybeConditional (/node_modules/acorn/dist/acorn.js:1993:21)
at Object.pp$3.parseMaybeAssign (/node_modules/acorn/dist/acorn.js:1968:21)
at Object.pp$3.parseExpression (/node_modules/acorn/dist/acorn.js:1933:21)
at Object.pp$1.parseStatement (/node_modules/acorn/dist/acorn.js:877:47)
at Object.pp$1.parseTopLevel (/node_modules/acorn/dist/acorn.js:746:23)
at Object.parse (/node_modules/acorn/dist/acorn.js:553:17)
at Function.parse (/node_modules/acorn/dist/acorn.js:576:37)
at Object.<anonymous> (/TEST.js:4:8)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at (internal/main/run_main_module.js:17:11)
The following throws an error:
class P {
delete = 5;
}
with the above is supported in eg Babel. Yet the corresponding class method definition is fine:
class P {
delete () {
}
}
I wonder if we should run the parseIdentifier
with liberal
to cater to this flexibility? I'm not sure which would be exactly correct by the spec, but I feel like it likely would be similar to class definitions surely?
... not 0.2.2 -- even though npm says that you published 22 days ago same that github says pushed the 0.2.2 version to github. I use acorn 7, so it's pretty necessary.
you must have mistakenly published the wrong version to npm.. the package.json has "version": "0.2.0"
which is probably how it happened. temporarily as a workaround I've set my package.json to point to this repository. just lettin you know, though..
cheers 👍
The newest version of acorn is 7 now, so could u remove the limitation of acorn@6 only?
OR I could make a PR if you wish.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.