Saturday, January 11, 2014

Dictionary – Remove Correction

A minor problem was discovered with the dictionary class, which can be demonstrated by entering the single statement "a=0" into an empty program and then introducing an error on the line (for example, "a=0b") and entering the line.  Once the error is removed, the line is recreated incorrectly as " = 0" (note the space where the "a" should be).

When the statement is first entered, the "a" variable gets entered into the dictionary as "A" (because variable names are case insensitive).  When the error is introduced, the statement is dereferenced (both the variable "a" and the constant "0" should be removed from the dictionaries).  However, when the attempt to remove "a" from the hash in the dictionary, it does not match the "A" that was put into the hash originally.  The dictionary item is removed (from the key list).  When the "a" is added back, the dictionary sees that it is already in the hash because it was not correctly removed and returns it index and the name doesn't get added back to the key list, which still has an empty name for the index.

This problem was corrected by adding a case sensitivity argument to the remove functions of the dictionary and info dictionary classes with a default of case insensitive (same as for the add functions).  For dictionaries that use the case sensitive option (remark and string constant), they must also use it when removing dictionary entries.  The remove function converts the obtained key from the key list for the index specified to upper case for a case insensitive dictionary so that the hash is properly removed.

[commit d7dec3ca11]

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)