-
-
Couldn't load subscription status.
- Fork 33.6k
assert: fix exception message for assert(0) on try catch block #46760
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
Changes from 1 commit
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -78,6 +78,7 @@ let isDeepEqual; | |||||
| let isDeepStrictEqual; | ||||||
| let parseExpressionAt; | ||||||
| let findNodeAround; | ||||||
| let tokenizer; | ||||||
| let decoder; | ||||||
|
|
||||||
| function lazyLoadComparison() { | ||||||
|
|
@@ -242,39 +243,42 @@ function getCode(fd, line, column) { | |||||
|
|
||||||
| function parseCode(code, offset) { | ||||||
| // Lazy load acorn. | ||||||
| if (parseExpressionAt === undefined) { | ||||||
| if (parseExpressionAt === undefined || tokenizer === undefined) { | ||||||
| const Parser = require('internal/deps/acorn/acorn/dist/acorn').Parser; | ||||||
| ({ findNodeAround } = require('internal/deps/acorn/acorn-walk/dist/walk')); | ||||||
|
|
||||||
| parseExpressionAt = FunctionPrototypeBind(Parser.parseExpressionAt, Parser); | ||||||
| tokenizer = FunctionPrototypeBind(Parser.tokenizer, Parser); | ||||||
| } | ||||||
| let node; | ||||||
| let start = 0; | ||||||
| let start; | ||||||
| // Parse the read code until the correct expression is found. | ||||||
| do { | ||||||
| for (const token of tokenizer(code, { ecmaVersion: 'latest' })) { | ||||||
| start = token.start; | ||||||
| if (start > offset) { | ||||||
| // No matching expression found. This could happen if the assert | ||||||
| // expression is bigger than the provided buffer. | ||||||
| break; | ||||||
| } | ||||||
| try { | ||||||
| node = parseExpressionAt(code, start, { ecmaVersion: 'latest' }); | ||||||
| start = node.end + 1 || start; | ||||||
| // Find the CallExpression in the tree. | ||||||
| node = findNodeAround(node, offset, 'CallExpression'); | ||||||
| } catch (err) { | ||||||
| // Unexpected token error and the like. | ||||||
| start += err.raisedAt || 1; | ||||||
| if (start > offset) { | ||||||
| // No matching expression found. This could happen if the assert | ||||||
| // expression is bigger than the provided buffer. | ||||||
| // eslint-disable-next-line no-throw-literal | ||||||
| throw null; | ||||||
| if (node && node.node.end >= offset) { | ||||||
|
||||||
| if (node && node.node.end >= offset) { | |
| if (node?.node.end >= offset) { |
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.
@BridgeAR
Got it. I will change this code.
Uh oh!
There was an error while loading. Please reload this page.
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.
The second condition is not needed due to the tokenizer and parseExpressionAt being defined at the same moment.
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.
@BridgeAR
Thanks for your feedback.
I see. I will revert this conditional expression back to the previous one.