Comments (3)
Ah, Haha. This is also a bit confusing for visit orders. I thought about it again. We can defer binding FunctionExpression
and ClassExpression
and bind them when we visit BindingIdentifier
.
from oxc.
@Dunqing Just to throw in my 2 cents, I wonder if FunctionExpression
and FunctionDeclaration
should be separate types (and each type would have Function
as a field within it). The 2 have various significant differences:
- One is a
Statement
, the other anExpression
. FunctionExpression
'sname
field should be anOption
, whereas it's compulsory inFunctionDeclaration
.- Scope should be entered before
name
forFunctionExpression
and after name forFunctionDeclaration
.
We could also have a separate type for ObjectMethod
(whose name
isn't a binding at all).
At present, it's possible to create non-sensical AST nodes (e.g. a FunctionDeclaration
with no name) - it'd be good to make this impossible through the type system.
from oxc.
@Dunqing Just to throw in my 2 cents, I wonder if
FunctionExpression
andFunctionDeclaration
should be separate types (and each type would haveFunction
as a field within it). The 2 have various significant differences:
- One is a
Statement
, the other anExpression
.FunctionExpression
'sname
field should be anOption
, whereas it's compulsory inFunctionDeclaration
.- Scope should be entered before
name
forFunctionExpression
and after name forFunctionDeclaration
.We could also have a separate type for
ObjectMethod
(whosename
isn't a binding at all).At present, it's possible to create non-sensical AST nodes (e.g. a
FunctionDeclaration
with no name) - it'd be good to make this impossible through the type system.
Yes, I talked with @Boshen about the above. Since they are not very different, they have been combined into one type. I agree we should have different types for FunctionExpression
and FunctionDeclaration
, and also class should be ClassExpression
and ClassDeclaration
- Scope should be entered before
name
forFunctionExpression
and after name forFunctionDeclaration
.
We bind in enter_node
. So we have to switch the order of enter_node
and enter_scope
to bind it to the corresponding scope. Or do something like #4195 (comment).
from oxc.
Related Issues (20)
- codegen: `__NO_SIDE_EFFECTS__` in vue.runtime.global.js
- Request for Enhanced JSON Output in Reporter HOT 3
- transformer: typescript syntax inside `SimpleAssignmentTarget` is not stripped
- codegen: `TSSatisfiesExpression` and `TSInstantiationExpression` is not printed
- linter: false positive in unicorn/no-useless-spread HOT 11
- Configure and check Minimum Supported Rust Version HOT 7
- Standardize conventions for transforms HOT 1
- Panic `byte index 7 is not a char boundary` in `oxc_span/src/span/mod.rs` HOT 1
- False positive for no-unused-vars HOT 4
- oxlint -v return 'dev' instead of '0.7.1' HOT 1
- Proposal: Support Multiple Config Files for Different Paths in LSP
- enhance eslint-plugin-react jsx-props-no-spread-multi to report member expressions
- `AstBuilder` methods which take an `Option` accept `None` without type annotation HOT 5
- traverse: port the `generateUidIdentifierBasedOnNode` method of the Babel scope. HOT 1
- playground: add transformer tab
- Panic `attempt to shift right with overflow` in `oxc_linter/src/utils/tree_shaking.rs`
- `CloneIn` unnecessarily copies strings when cloning within same allocator
- Proposal for JSON Output Enhancements to Support Node.js API Development HOT 1
- enhancement(linter) new rule proposal/expand no useless spread HOT 2
- CI: AST changes doesn't return exit code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oxc.