Page MenuHomePhabricator

Fix error handling after [<index>] in 'frame variable'

Authored by jarin on May 5 2020, 4:14 AM.



This fixes a bug where

frame var a[0]+5

returns the value a[0] without any warning because the current logic simply ignores everything after ']' as long as there is no '.', '-' or '[' in the rest of the string.

The fix simplifies the termination condition of the expression path parsing loop to check if have a non-empty remaining string to parse. Previously, the condition checked if a separator was found. That condition coincided with the remaining string-to-parse condition except for the buggy indexed case where non-empty string was left ("+5" in the example above), but the separator index was 'npos'.

Diff Detail

Event Timeline

jarin created this revision.May 5 2020, 4:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2020, 4:14 AM
jarin retitled this revision from Fix handling of [<index>] in 'frame variable' to Fix error handling after [<index>] in 'frame variable'.May 5 2020, 4:15 AM
labath accepted this revision.May 5 2020, 4:48 AM

Makes sense to me.

This revision is now accepted and ready to land.May 5 2020, 4:48 AM
jarin added a comment.May 5 2020, 4:58 AM

Do you think Raphael would want to review this as well? If you think it is not necessary, could you land the patch for me?

teemperor accepted this revision.May 5 2020, 1:50 PM

I don't think I know this code better than Pavel, but this also LGTM.

This revision was automatically updated to reflect the committed changes.