Skip to content

Commit dda8217

Browse files
authored
Merge pull request #498 from boriel/bugfix/dim_at_must_not_allow_initialization
Do not allow to declare initted arrays with AT
2 parents e7c01c8 + 4f1ff63 commit dda8217

6 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/parsetab/tabs.dbm.bak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
'zxbpp', (0, 73193)
22
'asmparse', (73216, 271961)
33
'zxnext_asmparse', (345600, 302573)
4-
'zxbparser', (648192, 703233)
4+
'zxbparser', (648192, 703160)

src/parsetab/tabs.dbm.dat

-73 Bytes
Binary file not shown.

src/parsetab/tabs.dbm.dir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
'zxbpp', (0, 73193)
22
'asmparse', (73216, 271961)
33
'zxnext_asmparse', (345600, 302573)
4-
'zxbparser', (648192, 703233)
4+
'zxbparser', (648192, 703160)

src/zxbc/zxbparser.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,8 @@ def p_decl_arr(p):
815815

816816

817817
def p_arr_decl_initialized(p):
818-
""" var_arr_decl : DIM idlist LP bound_list RP typedef RIGHTARROW const_vector
819-
| DIM idlist LP bound_list RP typedef EQ const_vector
818+
""" var_decl : DIM idlist LP bound_list RP typedef RIGHTARROW const_vector
819+
| DIM idlist LP bound_list RP typedef EQ const_vector
820820
"""
821821

822822
def check_bound(boundlist, remaining):
@@ -844,16 +844,14 @@ def check_bound(boundlist, remaining):
844844

845845
return True
846846

847+
p[0] = None
847848
if p[8] is None:
848-
p[0] = None
849849
return
850850

851851
if check_bound(p[4].children, p[8]):
852852
id_, lineno = p[2][0]
853853
SYMBOL_TABLE.declare_array(id_, lineno, p[6], p[4], default_value=p[8])
854854

855-
p[0] = None
856-
857855

858856
def p_bound_list(p):
859857
""" bound_list : bound
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
REM These are not allowed either => or AT can be used, but not both at once
2+
3+
dim test(0 to 3) as ubyte => {1,2,3,4} at $C000
4+
dim test2(0 to 3) as ubyte => {1,2,3,4} at $C000

tests/functional/test_errmsg.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ db256.asm:4: warning: [W200] Value will be truncated
193193
db256.asm:6: warning: [W200] Value will be truncated
194194
>>> process_file('opt2_unused_var1.bas')
195195
opt2_unused_var1.bas:2: warning: Variable 'a' is never used
196+
>>> process_file('dim_at_init_err.bas')
197+
dim_at_init_err.bas:3: error: Syntax Error. Unexpected token 'AT' <AT>
198+
dim_at_init_err.bas:4: error: Syntax Error. Unexpected token 'AT' <AT>
196199

197200
# Test warning silencing
198201
>>> process_file('mcleod3.bas', ['-S', '-q', '-O --expect-warnings=2'])

0 commit comments

Comments
 (0)