Nazir 2:7-8
Nazir 2:7
If a person says, “I’m a nazir when I have a son,” and he then has a son, he is a nazir. If he has a daughter, an intersex child (formerly referred to as "hermaphrodite"; in the language of the Mishna, "androginos") or a child of indeterminate gender (tumtum), he is not a nazir. If he says, “When I see I will have a child,” then he is a nazir even if he has a daughter, a tumtum or an androginos.
Nazir 2:8
If his wife miscarries, he is not a nazir. Rabbi Shimon says that he should observe nezirus, stating that if the fetus was viable, he is doing so as an obligation; if it wasn’t, he is doing so voluntarily. If his wife subsequently gives birth, he is a nazir. Rabbi Shimon says that he should say, “If the first fetus was viable, my first nezirus was obligatory and this one is voluntary. If it was not, my first nezirus was voluntary and this one is obligatory.”