File tree 2 files changed +13
-10
lines changed
2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -104,13 +104,14 @@ export class Parser {
104
104
get inAsync ( ) { return ( this . currentVarScope ( ) . flags & SCOPE_ASYNC ) > 0 && ! this . currentVarScope ( ) . inClassFieldInit }
105
105
106
106
get canAwait ( ) {
107
- if ( this . currentThisScope ( ) . inClassFieldInit ) return false
108
- for ( let i = this . scopeStack . length - 1 ; i >= 0 ; i -- ) {
109
- let scope = this . scopeStack [ i ]
110
- if ( scope . flags & SCOPE_CLASS_STATIC_BLOCK ) return false
111
- if ( scope . flags & SCOPE_FUNCTION ) return ( scope . flags & SCOPE_ASYNC ) > 0
107
+ const scope = this . currentVarScope ( )
108
+ if ( scope . flags & SCOPE_FUNCTION ) {
109
+ return ( scope . flags & SCOPE_ASYNC ) && ! scope . inClassFieldInit
112
110
}
113
- return ( this . inModule && this . options . ecmaVersion >= 13 ) || this . options . allowAwaitOutsideFunction
111
+ if ( scope . flags & SCOPE_TOP ) {
112
+ return ( ( this . inModule && this . options . ecmaVersion >= 13 ) || this . options . allowAwaitOutsideFunction ) && ! scope . inClassFieldInit
113
+ }
114
+ return false
114
115
}
115
116
116
117
get allowSuper ( ) {
Original file line number Diff line number Diff line change @@ -742,11 +742,13 @@ pp.parseClassField = function(field) {
742
742
743
743
if ( this . eat ( tt . eq ) ) {
744
744
// To raise SyntaxError if 'arguments' exists in the initializer.
745
- const scope = this . currentThisScope ( )
746
- const inClassFieldInit = scope . inClassFieldInit
747
- scope . inClassFieldInit = true
745
+ const thisScope = this . currentThisScope ( ) , varScope = this . currentVarScope ( )
746
+ const thisScopeInClassFieldInit = thisScope . inClassFieldInit
747
+ const varScopeInClassFieldInit = varScope . inClassFieldInit
748
+ thisScope . inClassFieldInit = varScope . inClassFieldInit = true
748
749
field . value = this . parseMaybeAssign ( )
749
- scope . inClassFieldInit = inClassFieldInit
750
+ thisScope . inClassFieldInit = thisScopeInClassFieldInit
751
+ varScope . inClassFieldInit = varScopeInClassFieldInit
750
752
} else {
751
753
field . value = null
752
754
}
You can’t perform that action at this time.
0 commit comments