Skip to content

Commit

Permalink
FIX: issue #5265 (Local words break SORT/COMPARE)
Browse files Browse the repository at this point in the history
  • Loading branch information
qtxie committed Jan 8, 2023
1 parent 8290def commit 2ee51cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion runtime/datatypes/block.reds
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,7 @@ block: context [
f [red-function!]
all? [logic!]
num [integer!]
cnt [integer!]
blk1 [red-block!]
blk2 [red-block!]
v1 [red-value!]
Expand Down Expand Up @@ -1250,7 +1251,9 @@ block: context [
s2/tail: value2 + num
]

_function/call f global-ctx as red-value! words/_compare-cb CB_SORT ;FIXME: hardcoded origin context
cnt: _function/count-locals f/spec 0 no
if positive? cnt [_function/init-locals cnt]
_function/call f f/ctx as red-value! words/_compare-cb CB_SORT

This comment has been minimized.

Copy link
@dockimbel

dockimbel Jan 8, 2023

Member

The f/ctx context is wrong, it's not the function's context that needs to be passed there, but either global context or a container object context.

This comment has been minimized.

Copy link
@dockimbel

dockimbel Jan 8, 2023

Member

The locals counting should not be done at this level, as this code is called for every pair of values comparison. It should be done before entering the sorting, as the locals count is a constant, and just passed down to that code.

This comment has been minimized.

Copy link
@qtxie

qtxie Jan 9, 2023

Author Contributor

Thank you. I'll fix it.

This comment has been minimized.

Copy link
@qtxie

qtxie Jan 9, 2023

Author Contributor

Pushed a fix in this branch.

I don't know how to fix the issue with refinement. #5265 (comment)

stack/unwind
stack/pop 1

Expand Down
5 changes: 4 additions & 1 deletion runtime/datatypes/string.reds
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,7 @@ string: context [
f [red-function!]
all? [logic!]
num [integer!]
cnt [integer!]
str1 [red-string!]
str2 [red-string!]
v1 [red-value!]
Expand Down Expand Up @@ -1373,7 +1374,9 @@ string: context [
s2/tail: as red-value! (value2 + (num << (log-b unit)))
]

_function/call f global-ctx as red-value! words/_compare-cb CB_SORT ;FIXME: hardcoded origin context
cnt: _function/count-locals f/spec 0 no
if positive? cnt [_function/init-locals cnt]
_function/call f f/ctx as red-value! words/_compare-cb CB_SORT

This comment has been minimized.

Copy link
@dockimbel

dockimbel Jan 8, 2023

Member

The f/ctx context is wrong, it's not the function's context that needs to be passed there, but either global context or a container object context.

stack/unwind
stack/pop 1

Expand Down

0 comments on commit 2ee51cb

Please sign in to comment.