VM: accessing the string terminator is not allowed anymore; cleanup tests/system/tostring.nim

This commit is contained in:
Andreas Rumpf 2018-07-17 18:22:20 +02:00
commit 2e3f477957
2 changed files with 13 additions and 8 deletions

View file

@ -533,8 +533,10 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
let s = regs[rb].node.strVal
if s.isNil:
stackTrace(c, tos, pc, errNilAccess)
elif idx <=% s.len:
elif idx <% s.len:
regs[ra].intVal = s[idx].ord
elif idx == s.len and optLaxStrings in c.config.options:
regs[ra].intVal = 0
else:
stackTrace(c, tos, pc, errIndexOutOfBounds)
of opcWrArr: