summaryrefslogtreecommitdiff
path: root/test/regress/2069.test
Commit message (Collapse)AuthorAgeFilesLines
* Avoid making references to nullKunht Kun2022-03-171-0/+16
In `compare_items` if `sort_order` is a top level expression, it has no context and `get_context()` method returns the null pointer. To see this, run $ ledger -f test/input/demo.ledger --sort display_amount reg --debug scope.symbols and there will be many lines like [DEBUG] Binding scope 0 with ... In such case making a reference to the context is an undefined behavior (honestly the dereferencing itself feels quite problematic, but many compilers just run without any complaints) and could potentially cause segfaults. Therefore, we change to use only the grandchild scope (`left` or `right`) for `find_sort_values` here. Note that it may seem to be more appropriate to use `report` here for the parent scope. However, in `find_sort_values` which is called right after, the `report` scope is always bound to this scope. So we only use grandchild scope to avoid unnecessary operations. Fixes #2069.