Skip to content

Commit 50ae786

Browse files
authored
Merge pull request #2308 from Shaikh-Ubaid/dims_error_message_format
Improve dims error message format
2 parents c1e8486 + f15d872 commit 50ae786

9 files changed

+13
-13
lines changed

src/libasr/asr_utils.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,15 +1091,15 @@ static inline std::string extract_dim_value(ASR::expr_t* dim) {
10911091

10921092
static inline std::string type_encode_dims(size_t n_dims, ASR::dimension_t* m_dims )
10931093
{
1094-
std::string dims_str = "";
1094+
std::string dims_str = "[";
10951095
for( size_t i = 0; i < n_dims; i++ ) {
10961096
ASR::dimension_t dim = m_dims[i];
1097-
dims_str += "[";
1098-
// dims_str += extract_dim_value(dim.m_start);
1099-
// dims_str += ",";
11001097
dims_str += extract_dim_value(dim.m_length);
1101-
dims_str += "]";
1098+
if (i + 1 < n_dims) {
1099+
dims_str += ",";
1100+
}
11021101
}
1102+
dims_str += "]";
11031103
return dims_str;
11041104
}
11051105

tests/reference/asr-arrays_05-ec8fbd5.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"stdout": null,
99
"stdout_hash": null,
1010
"stderr": "asr-arrays_05-ec8fbd5.stderr",
11-
"stderr_hash": "b92b252106c95d1851599993abbedd755f2b3231f5b551b3af33b67e",
11+
"stderr_hash": "4e5d42a186b8d82b484ec66ccc5a3b90da7e4be8a32bac26ea906198",
1212
"returncode": 2
1313
}

tests/reference/asr-arrays_05-ec8fbd5.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ semantic error: Type mismatch in annotation-assignment, the types must be compat
22
--> tests/errors/arrays_05.py:6:5
33
|
44
6 | x: i16[5, 4] = empty([5, 3], dtype=int16)
5-
| ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch ('i16[5][4]' and 'i16[5][3]')
5+
| ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch ('i16[5,4]' and 'i16[5,3]')

tests/reference/asr-arrays_06-fbb09a3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"stdout": null,
99
"stdout_hash": null,
1010
"stderr": "asr-arrays_06-fbb09a3.stderr",
11-
"stderr_hash": "0cd2825fa152a45c868b7f54832a95d0f457be296143f28ce1909870",
11+
"stderr_hash": "1fa3f5061a72f03c0678806c0460b9ec5caf01cbbd2f07a606f1057e",
1212
"returncode": 2
1313
}

tests/reference/asr-arrays_06-fbb09a3.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ semantic error: Type mismatch in annotation-assignment, the types must be compat
22
--> tests/errors/arrays_06.py:6:5
33
|
44
6 | x: i16[5, 4] = empty([5, 4], dtype=int32)
5-
| ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch ('i16[5][4]' and 'i32[5][4]')
5+
| ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch ('i16[5,4]' and 'i32[5,4]')

tests/reference/asr-arrays_07-de430fd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"stdout": null,
99
"stdout_hash": null,
1010
"stderr": "asr-arrays_07-de430fd.stderr",
11-
"stderr_hash": "ea9cadd25ae52d3ff115925e4f8e6feb278ad009410d64c940cf64ff",
11+
"stderr_hash": "7fadea44b4ad8f383e0cadbd27a53eb3ab75f0edef98d27639527723",
1212
"returncode": 2
1313
}

tests/reference/asr-arrays_07-de430fd.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ semantic error: Type mismatch in annotation-assignment, the types must be compat
22
--> tests/errors/arrays_07.py:6:5
33
|
44
6 | x: f32[5, 4] = empty([5, 4], dtype=complex64)
5-
| ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch ('f32[5][4]' and 'c32[5][4]')
5+
| ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch ('f32[5,4]' and 'c32[5,4]')

tests/reference/asr-arrays_08-ba317a3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"stdout": null,
99
"stdout_hash": null,
1010
"stderr": "asr-arrays_08-ba317a3.stderr",
11-
"stderr_hash": "a6fc0e1c661fab5e3ee0a034abb85d765a1dce515483a2a6191b2aa7",
11+
"stderr_hash": "bedb87b219b7c49a18cced170e4ffcac780d242f70c3ae8bbfb27a26",
1212
"returncode": 2
1313
}

tests/reference/asr-arrays_08-ba317a3.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ semantic error: Type mismatch in annotation-assignment, the types must be compat
22
--> tests/errors/arrays_08.py:9:5
33
|
44
9 | x: i64[p, q, r] = empty([q, p, r], dtype=int64)
5-
| ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch ('i64[100][120][200]' and 'i64[120][100][200]')
5+
| ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch ('i64[100,120,200]' and 'i64[120,100,200]')

0 commit comments

Comments
 (0)