-
-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
One of the rewrites in https://github.com/getgrit/stdlib/blob/main/.grit/patterns/go/useless_if_else_body.md is wrong.
It rewrites
if ($conditon) { $body } else { $body }
to
if ($conditon) { $body }
Oops. (Also, condition is misspelled, and Go doesn't support using integers as booleans in conditions. But those are less important.)
The other rewrites is only sometimes sound. Rewriting
if ($conditon) { $body } else if ($conditon) { $body }
to
if ($conditon) { $body }
is unsafe if evaluating the condition has side-effects.
Given GritQL's goals, that might be ok. But it might be worth a sentence in the docs there?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels