In theory, edge A should be square to prevent the gap, but edge B must be rounded since the complementary part is cut using a bit with some radius:
The same is true of the female part.
The difficult part is what to do at the corner where edge A and edge B intersect. It needs to be some compound curve and it is not obvious what the correct shape is.
I found this to be a fascinating mathematical puzzle and I posted my solution a couple years ago. (Spoilers if you want the fun of solving the problem yourself.)