-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
New diagnostic type, documentation, and test for if("x" || "y"), case "x" || "y": #993
base: master
Are you sure you want to change the base?
Conversation
Add files via upload
CLA Assistant Lite bot Thank you for your contribution! Like many free software projects, you must sign our Contributor License Agreement before we can accept your contribution. EDIT: All contributors have signed quick-lint-js' Contributor License Agreement (CLA-v1.md). |
I have read and hereby agree to quick-lint-js' Contributor License Agreement (CLA-v1.md). |
```typescript | ||
case "x" || "y": | ||
``` |
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.
Must fix: Examples with bad code belong in the first code block. Also, they must be syntactically valid aside from the diagnostic, so you must include a switch
statement.
|
||
A condition with a string literal will always evaluate to true | ||
|
||
```typescript |
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.
Nitpick: I prefer examples in documentation to be javascript
if possible.
@@ -2976,13 +2986,6 @@ | |||
diag_unexpected_colon_after_generic_definition, "E0331", \ | |||
diagnostic_severity::error, { source_code_span colon; }, \ | |||
MESSAGE(QLJS_TRANSLATABLE("':' should be 'extends' instead"), colon)) \ | |||
\ | |||
QLJS_DIAG_TYPE( \ |
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.
Must fix: I think you reverted someone else's commit by mistake (edec089?). Reintroduce this diagnostic.
for (span_size i = 0; i < ast->child_count() + 1; i++) { | ||
expression* lhs = ast->child(i)->without_paren(); | ||
expression* rhs = ast->child(i + 1)->without_paren(); |
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.
Must fix: Iterating to ast->child_count() + 1
looks wrong. It would mean we potentially access ast->child(ast->child_count())
(lhs) and ast->child(ast->child_count() + 1)
(rhs), which are out of bounds.
I think you meant ast->child_count() - 1
instead.
|
||
if ((lhs->kind() == expression_kind::literal && | ||
rhs->kind() == expression_kind::literal) ){ | ||
source_code_span op_span = ast->operator_spans_[i]; |
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.
Must fix: This code does not compile:
no member named 'operator_spans_' in 'quick_lint_js::expression::conditional'
feat: added diagnostic type, documentation, and test case for issue #953
production code not completed yet