fix: 3 RDD compat bugs — FIELD->, AsNumInt Double, PACK/ZAP with index

Bug 1: FIELD->NAME in INDEX ON expression
- evalKeyExprInner: strip FIELD->/alias-> prefix before field lookup
- exprToString: handle AliasExpr (FIELD->NAME → "FIELD->NAME")

Bug 2: AsNumInt() on Double returned IEEE 754 raw bits
- Value.AsNumInt(): check tDouble and convert via Float64frombits
- Fixed array index crash when index is result of % modulo

Bug 3: PACK/ZAP crash with open indexes
- OrderListRebuild: fully implemented (was TODO stub)
  Saves index info, closes all, sets idxState=nil, recreates
- OrderCreate: set current=-1 during key evaluation (natural GoTo)
- PACK/ZAP: save/restore idxState, rebuild after operation
- Register __DBPACK, __DBZAP, DBRECALL symbol aliases

Harbour vs Five: 45/47 match (96%), 2 diffs are duplicate-key sort order

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-06 04:41:19 +09:00
parent 53370e7cbc
commit 6e78d12cc2
6 changed files with 108 additions and 7 deletions

View File

@@ -17,7 +17,7 @@ PROCEDURE Main()
APPEND BLANK
REPLACE ID WITH i
REPLACE NAME WITH PadR("Name_" + LTrim(Str(i)), 20)
nIdx := Int(((i-1) % 5)) + 1
nIdx := ((i-1) % 5) + 1
REPLACE CITY WITH PadR(aCities[nIdx], 15)
REPLACE SALARY WITH 30000 + i * 1000.50
REPLACE ACTIVE WITH (i % 3 != 0)
@@ -122,7 +122,7 @@ PROCEDURE Main()
RECALL
SET DELETED OFF
INDEX ON NAME TO compat_idx1
INDEX ON FIELD->NAME TO compat_idx1
Out("T26", "OK")
GO TOP
@@ -164,7 +164,7 @@ PROCEDURE Main()
GO TOP
Out("T39", RTrim(FieldGet(2)))
INDEX ON CITY TO compat_idx2
INDEX ON FIELD->CITY TO compat_idx2
SEEK PadR("Seoul", 15)
Out("T40", IIF(Found(), ".T.", ".F.") + " " + LTrim(Str(FieldGet(1))))