fix: handle subscripts correctly when nested in expr within array function call #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The primary part of this fix was to keep track of the current array function in a separate variable,
currentArrayFunctionName
, and use that in a couple places instead of accessing the most directcurrentFunctionName
, which is not accurate in the case of nested expressions.As part of this, I changed
LOOKUP
so that it returns:NA:
when the givenLookup
is NULL, which can happen in the case of sparse datasets. I made this change here since the newsumif
test case uses a sparse matrix (i.e., it's purposely missing data in one dimension).I also changed
initMode
tomode
and made the values more explicit, because I found that the previous approach was not fine-grained enough and would cause lookups to sometimes be initialized redundantly (for example, if a lookup is referenced inside ofinitLevels
). With this new approach, we're more clear about whether we are in "decl" mode, or a specific kind of "init" mode, or "eval" mode.Fixes #46