Skip to content

Commit aff543e

Browse files
authored
Merge pull request #2507 from tanay-man/main
Fixed issue #1993 to improve readability of semantic error thrown
2 parents 0b9f575 + 4d5c412 commit aff543e

7 files changed

+7
-7
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
886886
);
887887
throw SemanticAbort();
888888
} else {
889-
throw SemanticError("Unsupported type annotation: " + var_annotation, loc);
889+
throw SemanticError("The type '" + var_annotation+"' is undeclared.", loc);
890890
}
891891
}
892892

tests/reference/asr-test_annassign_01-2f18669.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-test_annassign_01-2f18669.stderr",
11-
"stderr_hash": "f3609cdad6bdb1be4a138587d5d36d0a28b71e4e51bb1304c2d2a01f",
11+
"stderr_hash": "28c68e6612db1644548768280ac3d35d3735a13cd32c04da44cec570",
1212
"returncode": 2
1313
}

tests/reference/asr-test_annassign_01-2f18669.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
semantic error: Unsupported type annotation: Optional
1+
semantic error: The type 'Optional' is undeclared.
22
--> tests/errors/test_annassign_01.py:2:8
33
|
44
2 | a: Optional[i32] = 5

tests/reference/asr-test_annassign_02-accf6db.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-test_annassign_02-accf6db.stderr",
11-
"stderr_hash": "3a426fad190cfcadc94dd971acc709446147d8a63658953bfbb94771",
11+
"stderr_hash": "1183fbf06e8412166eb5ca96b5b07cec67382752789a96c7c04c1950",
1212
"returncode": 2
1313
}

tests/reference/asr-test_annassign_02-accf6db.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
semantic error: Unsupported type annotation: Pattern
1+
semantic error: The type 'Pattern' is undeclared.
22
--> tests/errors/test_annassign_02.py:2:15
33
|
44
2 | hex_pat : Pattern[str] = r'-?0[xX]+'

tests/reference/asr-test_unsupported_type-0d813dd.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-test_unsupported_type-0d813dd.stderr",
11-
"stderr_hash": "1675de57db132a5a4a589070d7c54ff23a57532bd967ccb416ff8c2a",
11+
"stderr_hash": "df2464bbcb9d52d4dbe40236762e965b1b771406f16ef90cf53b8611",
1212
"returncode": 2
1313
}

tests/reference/asr-test_unsupported_type-0d813dd.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
semantic error: Unsupported type annotation: i128
1+
semantic error: The type 'i128' is undeclared.
22
--> tests/errors/test_unsupported_type.py:2:8
33
|
44
2 | i: i128

0 commit comments

Comments
 (0)