Improve error message for illegal use of variable in map key, closes #2083