Inversion after 'only when', 'only after', 'only if', 'only in this way' etc

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.


Solution 1:

Yes, you are correct. As is the case with other negative adverbials, inversion is required after 'only when ...'.

This grammaring article gives the rule and examples:

When only after, only if, only in this way etc. are placed at the beginning of the sentence for rhetorical effect, the subject and auxiliary are inverted:

Only after lunch can you play. (You can only play after lunch.)

Only after finishing your homework can you play. (You can only play after you finish your homework.)

Only after you have finished your homework can you play. (You can only play after you have finished your homework.)

Only by guessing can you solve this puzzle. (You can only solve this puzzle by guessing.)

Only if everybody agreed would I accept this position. (I would only accept this position if everybody agreed.)

Only in this way does this machine work. (This machine only works in this way.)

Only then did they discover his secret. (They only discovered his secret then.)

Only when he needed some help did he call me. (He only called me when he needed some help.)

Only when I filled my glass did I notice that it was broken. (I only noticed that my glass was broken when I filled it.)

This To Learn English article gives a wider range of negative adverbials.