Skip to content

Commit a43184e

Browse files
committed
Array begin fix
1 parent fafef63 commit a43184e

16 files changed

+102
-644
lines changed

integration_tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,8 @@ endmacro(COMPILE)
417417

418418

419419
# Test zero and non-zero exit code and assert statements
420-
# RUN(NAME array_01_decl LABELS cpython llvm llvm_jit c)
421-
# RUN(NAME array_02_decl LABELS cpython llvm llvm_jit c)
420+
RUN(NAME array_01_decl LABELS cpython llvm llvm_jit c)
421+
RUN(NAME array_02_decl LABELS cpython llvm llvm_jit c)
422422
RUN(NAME array_03_decl LABELS cpython llvm llvm_jit) # renable c
423423
RUN(NAME variable_decl_01 LABELS cpython llvm llvm_jit c)
424424
RUN(NAME variable_decl_02 LABELS cpython llvm llvm_jit c)

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,10 +1891,12 @@ class CommonVisitor : public AST::BaseVisitor<StructType> {
18911891
ASR::ttype_t* type = get_type_from_var_annotation(var_annotation,
18921892
annotation.base.loc, dims, type_decl, m_args, n_args, raise_error, abi, is_argument);
18931893

1894+
ASR::expr_t* zero = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc, 0, ASRUtils::TYPE(
1895+
ASR::make_Integer_t(al, loc, 4))));
18941896
if (AST::is_a<AST::Slice_t>(*dim_info)) {
18951897
ASR::dimension_t dim;
18961898
dim.loc = loc;
1897-
dim.m_start = nullptr;
1899+
dim.m_start = zero;
18981900
dim.m_length = nullptr;
18991901
dims.push_back(al, dim);
19001902
} else if( is_runtime_array(dim_info) ) {
@@ -1903,7 +1905,7 @@ class CommonVisitor : public AST::BaseVisitor<StructType> {
19031905
if( AST::is_a<AST::Slice_t>(*tuple_multidim->m_elts[i]) ) {
19041906
ASR::dimension_t dim;
19051907
dim.loc = loc;
1906-
dim.m_start = nullptr;
1908+
dim.m_start = zero;
19071909
dim.m_length = nullptr;
19081910
dims.push_back(al, dim);
19091911
}

tests/reference/asr-array_01_decl-39cf894.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-array_01_decl-39cf894.stdout",
9-
"stdout_hash": "8355e703ff669698e75aa05f3a0b0b56c0818989cbd2b110662c8c62",
9+
"stdout_hash": "195a4d1ca41ba5c8ed64f7af675a59ef0100f236e0f63fcbb6c771aa",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/asr-array_01_decl-39cf894.stdout

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
Default
139139
(Array
140140
(Real 4)
141-
[(()
141+
[((IntegerConstant 0 (Integer 4) Decimal)
142142
())]
143143
DescriptorArray
144144
)
@@ -158,7 +158,7 @@
158158
(FunctionType
159159
[(Array
160160
(Real 4)
161-
[(()
161+
[((IntegerConstant 0 (Integer 4) Decimal)
162162
())]
163163
DescriptorArray
164164
)]
@@ -259,7 +259,7 @@
259259
Default
260260
(Array
261261
(Real 8)
262-
[(()
262+
[((IntegerConstant 0 (Integer 4) Decimal)
263263
())]
264264
DescriptorArray
265265
)
@@ -279,7 +279,7 @@
279279
(FunctionType
280280
[(Array
281281
(Real 8)
282-
[(()
282+
[((IntegerConstant 0 (Integer 4) Decimal)
283283
())]
284284
DescriptorArray
285285
)]
@@ -372,7 +372,7 @@
372372
Default
373373
(Array
374374
(Integer 2)
375-
[(()
375+
[((IntegerConstant 0 (Integer 4) Decimal)
376376
())]
377377
DescriptorArray
378378
)
@@ -392,7 +392,7 @@
392392
(FunctionType
393393
[(Array
394394
(Integer 2)
395-
[(()
395+
[((IntegerConstant 0 (Integer 4) Decimal)
396396
())]
397397
DescriptorArray
398398
)]
@@ -487,7 +487,7 @@
487487
Default
488488
(Array
489489
(Integer 4)
490-
[(()
490+
[((IntegerConstant 0 (Integer 4) Decimal)
491491
())]
492492
DescriptorArray
493493
)
@@ -507,7 +507,7 @@
507507
(FunctionType
508508
[(Array
509509
(Integer 4)
510-
[(()
510+
[((IntegerConstant 0 (Integer 4) Decimal)
511511
())]
512512
DescriptorArray
513513
)]
@@ -597,7 +597,7 @@
597597
Default
598598
(Array
599599
(Integer 8)
600-
[(()
600+
[((IntegerConstant 0 (Integer 4) Decimal)
601601
())]
602602
DescriptorArray
603603
)
@@ -617,7 +617,7 @@
617617
(FunctionType
618618
[(Array
619619
(Integer 8)
620-
[(()
620+
[((IntegerConstant 0 (Integer 4) Decimal)
621621
())]
622622
DescriptorArray
623623
)]

tests/reference/asr-array_02_decl-e8f6874.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-array_02_decl-e8f6874.stdout",
9-
"stdout_hash": "81b93da5b058c94b643f33808524512538dc0ddcbdc96d44b2a8db7d",
9+
"stdout_hash": "4476d6d9afeb815f77c878127aeb852c2c7a9ad4e4e105e5b5762e82",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/asr-array_02_decl-e8f6874.stdout

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
Default
8181
(Array
8282
(Real 4)
83-
[(()
83+
[((IntegerConstant 0 (Integer 4) Decimal)
8484
())]
8585
DescriptorArray
8686
)
@@ -100,7 +100,7 @@
100100
(FunctionType
101101
[(Array
102102
(Real 4)
103-
[(()
103+
[((IntegerConstant 0 (Integer 4) Decimal)
104104
())]
105105
DescriptorArray
106106
)]
@@ -176,9 +176,9 @@
176176
Default
177177
(Array
178178
(Real 8)
179-
[(()
179+
[((IntegerConstant 0 (Integer 4) Decimal)
180180
())
181-
(()
181+
((IntegerConstant 0 (Integer 4) Decimal)
182182
())]
183183
DescriptorArray
184184
)
@@ -198,9 +198,9 @@
198198
(FunctionType
199199
[(Array
200200
(Real 8)
201-
[(()
201+
[((IntegerConstant 0 (Integer 4) Decimal)
202202
())
203-
(()
203+
((IntegerConstant 0 (Integer 4) Decimal)
204204
())]
205205
DescriptorArray
206206
)]
@@ -279,9 +279,9 @@
279279
Default
280280
(Array
281281
(Integer 4)
282-
[(()
282+
[((IntegerConstant 0 (Integer 4) Decimal)
283283
())
284-
(()
284+
((IntegerConstant 0 (Integer 4) Decimal)
285285
())]
286286
DescriptorArray
287287
)
@@ -301,9 +301,9 @@
301301
(FunctionType
302302
[(Array
303303
(Integer 4)
304-
[(()
304+
[((IntegerConstant 0 (Integer 4) Decimal)
305305
())
306-
(()
306+
((IntegerConstant 0 (Integer 4) Decimal)
307307
())]
308308
DescriptorArray
309309
)]
@@ -382,11 +382,11 @@
382382
Default
383383
(Array
384384
(Integer 8)
385-
[(()
385+
[((IntegerConstant 0 (Integer 4) Decimal)
386386
())
387-
(()
387+
((IntegerConstant 0 (Integer 4) Decimal)
388388
())
389-
(()
389+
((IntegerConstant 0 (Integer 4) Decimal)
390390
())]
391391
DescriptorArray
392392
)
@@ -406,11 +406,11 @@
406406
(FunctionType
407407
[(Array
408408
(Integer 8)
409-
[(()
409+
[((IntegerConstant 0 (Integer 4) Decimal)
410410
())
411-
(()
411+
((IntegerConstant 0 (Integer 4) Decimal)
412412
())
413-
(()
413+
((IntegerConstant 0 (Integer 4) Decimal)
414414
())]
415415
DescriptorArray
416416
)]

tests/reference/asr-elemental_01-b58df26.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-elemental_01-b58df26.stdout",
9-
"stdout_hash": "74f282da0fbe04a8f9539f78cca9936b1336f906473653abc029f409",
9+
"stdout_hash": "43c58e449c81939272beda14f5f2831d2da66a9a50179f7c32a84c6e",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

0 commit comments

Comments
 (0)