You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible for a user to misplace an enforcement comment and thereby think enforcement is going to occur even when it doesn't, leading to bugs. Enforcement comments that don't end up touching a switch or map should raise an error.
The same might be said about any //exhaustive:ignore comments that aren't applied to any valid AST nodes.
The text was updated successfully, but these errors were encountered:
To implement this, it seems that the program would need to visit all AST nodes, not just SwitchStmt (switch statements), CompositeLit (map literals), and GenDecl (enum constants) nodes, as the program currently does. Visiting all nodes may have an effect on the program's performance. So, perhaps, the check for invalid directive comments should be behind a flag, and the flag's description can mention the possible additional performance cost.
I'm starting to think it would be better to create a separate analyzer just for this purpose. Other analyzers (e.g. exhaustruct) might also have directives that should only be applied to certain nodes. It would be more efficient to do a single analyzer pass to run over all nodes and check for mismatches. It wouldn't allow for as much nuanced validations but that could be handled by individual analyzers.
It is possible for a user to misplace an enforcement comment and thereby think enforcement is going to occur even when it doesn't, leading to bugs. Enforcement comments that don't end up touching a switch or map should raise an error.
The same might be said about any
//exhaustive:ignore
comments that aren't applied to any valid AST nodes.The text was updated successfully, but these errors were encountered: