Skip to content

Commit 2af7db7

Browse files
committed
COMMON: Fix square bracket field access issue
1 parent c816a69 commit 2af7db7

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

ChangeLog

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
2021-01-18 (12.21)
1+
2021-03-21 (12.21)
2+
COMMON: Fix square bracket field access issue
3+
4+
2021-02-23 (12.21)
25
COMMON: Fix crash when line length limit exceeded
36

47
2021-01-18 (12.21)

samples/distro-examples/tests/array.bas

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,4 +313,12 @@ next i
313313
m[1,2,3,4,5,6]=999
314314
if (999 <> m[1,2,3,4,5,6]) then
315315
throw "e"
316-
endif
316+
endif
317+
318+
REM test that "[0, 0]" in anims[0].framePoses[0, 0].translation is not scanned as a codearray
319+
dim amims(0 to 1)
320+
dim j(0 to 1, 0 to 1)
321+
j[0, 0].translation = [1,2,3]
322+
k.framePoses = j
323+
anims << k
324+
z=anims[0].framePoses[0, 0].translation

src/common/scan.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,10 +1331,11 @@ void comp_expression(char *expr, byte no_parser) {
13311331
// string
13321332
ptr = bc_store_string(&bc, ptr);
13331333
} else if (*ptr == '[') {
1334-
// code-defined array
1334+
// potential code-defined array
13351335
ptr++;
13361336
level++;
1337-
if (comp_is_code_array(&bc, ptr)) {
1337+
// can't be a code array if this is already part of a variable
1338+
if ((bc.size == 0 || bc.ptr[0] != kwTYPE_VAR) && comp_is_code_array(&bc, ptr)) {
13381339
// otherwise treat as array index
13391340
bc_add_fcode(&bc, kwCODEARRAY);
13401341
}

0 commit comments

Comments
 (0)