As said in Go documentation on Semicolons:
Like C, Go's formal grammar uses semicolons to terminate statements, but unlike in C, those semicolons do not appear in the source. Instead the lexer uses a simple rule to insert semicolons automatically as it scans, so the input text is mostly free of them.
Thus the presence of a semicolon at the end of a statement does not mean that a statement follows.
The rule raises a False Positive when a jump statement is followed by a semicolon:
func fn(myvar int) int { return myvar; // False positive }
The semicolon is superfluous but there is no dead code.
Note that there is a similar issue for RSPEC-122 (SONARSLANG-449)
- implements
-
RSPEC-1763 All code should be reachable
- Active
- is related to
-
SONARSLANG-449 [Go] - FP on S122 when a semicolon is added
-
- Closed
-