I guess the title says it all.
If I see someone post an answer that is correct in thought and solution, but has some syntactic problems due to being tailored for a different dialect of the programming language used or for a different system than the one used in the question and I comment on the answer that the syntax is off but the idea correct, should I take the liberty of correcting the syntax in the answer so that it becomes valid?
I'm not sure what to do here - I know it can be seen as rude, offensive and maybe misrepresenting the intent of the author to change an answer, but at the same time it would increase the quality of the post.
For the sake of argument let's assume the question and answer is trivial and that I'm 100% sure about the change.