-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
assert: fix exception message for assert(0) on try catch block #46760
assert: fix exception message for assert(0) on try catch block #46760
Conversation
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.
Great work! LGTM
lib/assert.js
Outdated
@@ -242,39 +243,42 @@ function getCode(fd, line, column) { | |||
|
|||
function parseCode(code, offset) { | |||
// Lazy load acorn. | |||
if (parseExpressionAt === undefined) { | |||
if (parseExpressionAt === undefined || tokenizer === undefined) { |
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.
if (parseExpressionAt === undefined || tokenizer === undefined) { | |
if (parseExpressionAt === undefined) { |
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.
lib/assert.js
Outdated
// expression is bigger than the provided buffer. | ||
// eslint-disable-next-line no-throw-literal | ||
throw null; | ||
if (node && 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.
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.
Landed in 3c0131a |
Fixes: #30872