allow addressing elements of openArray[char] in VM (#22045)

allow addressing elements of openArray[char]

(cherry picked from commit a8d0dda833)
This commit is contained in:
ringabout
2023-06-08 20:08:49 +08:00
committed by narimiran
parent 8f102f9e62
commit e8ec3efd3d
2 changed files with 16 additions and 0 deletions

View File

@@ -772,6 +772,8 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
else:
if src.kind notin {nkEmpty..nkTripleStrLit} and idx <% src.len:
takeAddress regs[ra], src.sons[idx]
elif src.kind in nkStrKinds and idx <% src.strVal.len:
regs[ra] = takeCharAddress(c, src, idx, pc)
else:
stackTrace(c, tos, pc, formatErrorIndexBound(idx, src.safeLen-1))
of opcLdStrIdx: