Is it correct to change a syntax error in code that has been posted as part of a question?

After pointing out in the comments that there was a syntax error in the code posted in this question (in particular in this revision), somebody then told me they though it was just "a typo" and proceeded to fix the syntax.

I tried to point out that I don't agree with assuming that syntax errors are always typos, because the OP might not be using software with syntax-highlighting (e.g. notepad, wordpad, etc), and the syntax error might actually be a major part of the problem.

Changing it without confirmation from the OP that it was a typo on the creation of the question could result in people being sent on a wild goose chase.

In this particular case the major part of the problem appears to something complete different, but I still don't think we can always assume syntax errors in posted code are a result of typos.

So, my question remains, should we be changing syntax errors in questions?


I agree with all comments so far... we should NOT assume syntax errors in code are simple typos, and certainly NOT change them on behalf of the OP (unless confirmed by the OP).

I have rolled back the question to the original, and then formatted it to make it more readable (but left in the syntax error / "typo").

I have also placed the following comment for the original editor to explain the situation...

@VisioN, sorry, but I have rolled-back this to the original revision of the question, because I do not believe anybody should assume that the code in the question has an error due to a "typo". Please see this Meta discussion for my reasons.

  • 3
    I would not edit it, but point it out in a comment.
    – asawyer
    Commented Oct 29, 2012 at 14:53
  • @asawyer, that is exactly what I did - somebody else "fixed the typo" in the question, not me
    – freefaller
    Commented Oct 29, 2012 at 14:54
  • If I see edits like that in the review queue I reject them as too radical. Not sure what else I can do.
    – asawyer
    Commented Oct 29, 2012 at 14:55
  • 1
    Oftentimes syntax errors in code that the OP says compiles means they didn't correctly post the code in the question. This is useful to me as it tells me we're not seeing the real code, so I can't trust that the posted code actually has the problem that the OP describes. If the syntax error is fixed that "clue" goes away.
    – Servy
    Commented Oct 29, 2012 at 14:59

1 Answer 1


No, code in the question should never be "corrected" on the assumption that it's a typo. If this ends up sending people on a wild good-chase, that's an unfortunate side-effect, but no real harm is done.

The OP should be asked to confirm whether or not it's a typo. "Fixing it" might simply end up hiding what the problem was all along.

By all means feel free to answer the question under the assumption that there is a typo which can be ignored. You might even explicitly point this out. But don't touch the question itself.

  • Thank you @Bart, I totally agree with you - so should I be rolling back this question to the "typo" version? I did put a comment saying I didn't agree with the edit, but there has been no response from the OP or the editor
    – freefaller
    Commented Oct 29, 2012 at 15:00
  • @freefaller I wouldnt see anything wrong with rolling it back, if that was all that was edited.
    – asawyer
    Commented Oct 29, 2012 at 15:03
  • @Bart, other than the formatting of the code for white-space reasons, it is the only change to the code
    – freefaller
    Commented Oct 29, 2012 at 15:08
  • I would personally not hesitate to roll it back. Perhaps include a link to this question in your edit message so it's clear what you base the rollback upon. Blame me if you want. :p
    – Bart
    Commented Oct 29, 2012 at 15:12
  • I won't blame you directly, but I'll leave that option available for future use ;-) I updated my question with my actions. Thanks @Bart.
    – freefaller
    Commented Oct 29, 2012 at 15:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .