Fix range expression defect MAGN-5111

This pull request fixes [MAGN-5111: Crash when step range expression come to infinity.](http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-5111)

Add more validity checks. 

@aparajit-pratap  please help to review the change.