Leibniz was extremely close to 'discovering' modal logic. He definitely understood the difference between intension and extension, and knew about valuations as functions from possible worlds. And I don't mean that one can "extract" this from his writings by reading hard between the lines -- it is quite explicit, and in many manuscripts. He did not, of course, have the formal tools in hand needed to formalize these ideas, but then again no one did until the work of Frege after 1880 and Russell after 1900. That's a 200 year gap!