fix($parse): properly handle dots at the end of identifiers

Fixes #4613
Fixes #4912
slice produces new string === garbage, let's use ident[ident.length -1] instead