This question popped into my head when I was watching Kingdom of Heaven, where the (historically inaccurate) protagonist's father just decides to have him inherit, even though it seems it should've gone to his nephew.
Even if it was so decreed, how likely would it be followed once the lord has died?
I am assuming if it came to this the lord would have no legitimate son, though if a case exist in which a lord rather his bastard son inherit over his legitimate one, please let me know too.
This is one of those things that occasionally happened but was decidedly nonstandard. Probably the most famous example is when Robert of Nomandy died on Crusade and left his Duchy to his illegitimate teenage son William. While Robert certainly didnt plan to die while outremer, he does seem to have intended William to inherit in the absence of further legitimate heirs being produced. This inheritance was not without critics, and William the Bastard (as he was known at the time) had to spend the first 15 years of his reign putting down rebellions by local counts and other minor lords that thought his rule without legal legitimacy.
The king of France, however, generally supported Williams claim to being Duke of Normandy. Why King Francis did this is not entirely clear to me -- presumably he felt William was less troublesome than the alternatives.
Later in life William the Bastard would go on to invade England in 1066