Skip to content

Commit 7b142b6

Browse files
committed
Fix string base not being used
Not used when assigning a subtring of in an array element. It should be used. Fixed.
1 parent bbfb7e9 commit 7b142b6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

zxbparser.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,20 @@ def make_array_substr_assign(lineno, id_, arg_list, substr, expr_):
320320
if expr_ is None:
321321
return None # There were errors
322322

323-
s0 = make_typecast(TYPE.uinteger, substr[0], lineno)
323+
str_idx_type = _TYPE(gl.STR_INDEX_TYPE)
324+
s0 = make_typecast(str_idx_type, substr[0], lineno)
324325
if s0 is None:
325326
return None # There were errors
326327

327-
s1 = make_typecast(TYPE.uinteger, substr[1], lineno)
328+
s1 = make_typecast(str_idx_type, substr[1], lineno)
328329
if s1 is None:
329330
return None # There were errors
330331

332+
if OPTIONS.string_base.value:
333+
base = make_number(OPTIONS.string_base.value, lineno, _TYPE(gl.STR_INDEX_TYPE))
334+
s0 = make_binary(lineno, 'MINUS', s0, base, func=lambda x, y: x - y)
335+
s1 = make_binary(lineno, 'MINUS', s1, base, func=lambda x, y: x - y)
336+
331337
return make_sentence('LETARRAYSUBSTR', arr, s0, s1, expr_)
332338

333339

0 commit comments

Comments
 (0)