I've learned it is obligatory to invert subject and verb when 'only when' is placed at the beginning of a sentence. However, I've recently found the sentence below.
"Only when the rule can have some meaningful effect it is to be applied."
Some English teacher in my country said this sentence is grammatically correct. He said inversion shouldn't happen in this case because a pronoun 'it' is used as a subject in the main clause and 'it' refers to 'the rule'. I'm not sure whether or not the sentence is correct, but I'm pretty sure that teacher doesn't know what he is talking about.
I think that sentence should be "Only when the rule can have some meaningful effect is it to be applied."
What do you think? Is it incorrect? If so, why is that?
Many thanks in advance.