Fix Coverity issue 1212320

Coverity was correctly complaining about the primitive PRIM_FIELD_NUM_TO_NAME.
If the field number specified exceeded the number of fields in the record or
class, then the compiler would not modify the variable name before using it,
causing a dereference of null.  I have added a test for this case and an error
message to the user should this occur in their code.
Merge pull request #570 from lydia-duncan/coverity1212320

Fix Coverity issue 1212320 [reviewed by bradc]

Coverity was correctly complaining about the primitive PRIM_FIELD_NUM_TO_NAME.
If the field number specified exceeded the number of fields in the record or
class, then the compiler would not modify the variable name before using it,
causing a dereference of null. I have added a test for this case and an error
message to the user should this occur in their code.