google / google/closure-compiler

Incorrect JSDoc validation in CheckJSDoc pass

Open
#2,541 1 comment 0 reactions 0 assignees View on GitHub
P3
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Bug in `CheckJSDoc` compiler pass; the test `testJSDocDescAttachment` checking for `MISPLACED_MSG_ANNOTATION` does not pass when there is no `EXTRA` token (i.e. when there is not an extra semi-colon at the end of the expression).

Consider:

**A**
```
testWarning(
"function f() { return /** @type {string} */ (g(1 /** @desc x */)); }",
MISPLACED_MSG_ANNOTATION);
```
vs.

**B**
```
testWarning(
"function f() { return /** @type {string} */ (g(1 /** @desc x */)); };",
MISPLACED_MSG_ANNOTATION);
```
Test A (which does not have an extra semi-colon, and therefore does not has the `EXTRA` token as part of its AST) fails, while Test B passes.

A/N: Warning handled by `validateMsgJsDoc(...)` method in `CheckJSDoc.java`; since `EXTRA` not handled as a case in switch statement, `!descOkay` evaluates to TRUE and the compiler reports warning `MISPLACED_MSG_ANNOTATION`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.