fix hashing of rationals (#9264)
Merge pull request #9265 from simonbyrne/hash-rational

fix hashing of rationals (#9264)