New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix several edge cases with context expression state #8972
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import * as N from "../types"; | |
import type { Options } from "../options"; | ||
import type { Pos, Position } from "../util/location"; | ||
import type State from "../tokenizer/state"; | ||
import { types as tc } from "../tokenizer/context"; | ||
import * as charCodes from "charcodes"; | ||
import { isIteratorStart } from "../util/identifier"; | ||
|
||
|
@@ -2392,7 +2393,10 @@ export default (superClass: Class<Parser>): Class<Parser> => | |
refNeedsArrowPos?: ?Pos, | ||
): N.Expression { | ||
let jsxError = null; | ||
if (tt.jsxTagStart && this.match(tt.jsxTagStart)) { | ||
if ( | ||
this.hasPlugin("jsx") && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to replace this, as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that are the most hard to debug test failures 🤦♂️ |
||
(this.match(tt.jsxTagStart) || this.isRelational("<")) | ||
) { | ||
const state = this.state.clone(); | ||
try { | ||
return super.parseMaybeAssign( | ||
|
@@ -2408,7 +2412,10 @@ export default (superClass: Class<Parser>): Class<Parser> => | |
// Remove `tc.j_expr` and `tc.j_oTag` from context added | ||
// by parsing `jsxTagStart` to stop the JSX plugin from | ||
// messing with the tokens | ||
this.state.context.length -= 2; | ||
const cLength = this.state.context.length; | ||
if (this.state.context[cLength - 1] === tc.j_oTag) { | ||
this.state.context.length -= 2; | ||
} | ||
|
||
jsxError = err; | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
for (const {a} of /b/) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment which explains that when this function is called we already know that there is a
function
token?