Sometimes, someone will post code asking a question and have other, unrelated errors, and people will answer and address only those errors. These errors are unrelated to the actual question topic.
I recently downvoted an answer such as this - an answer I, as a potential future viewer of the question (from google searching, or otherwise) would have not found relevant at all. Even though the answer was 100% informative to the user asking the question it still did not address the question.
Is this sort of situation a situation where a downvote is appropriate? Or are there alternative ways to respond which are better?
A practical example would be - Sub or Function not defined
That answer is technically correct and addresses other bugs in the question's code but does not answer the actual question.