Skip to content

Commit 942cffe

Browse files
Improved int semantic error message with hint (Issue #1926)
1 parent 7372627 commit 942cffe

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -877,9 +877,15 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
877877

878878
if( !type && raise_error ) {
879879
if (var_annotation == "int") {
880-
throw SemanticError(var_annotation + " type is not supported yet. " , loc);
881-
} else
882-
{
880+
std::string msg = "Hint: Use i8, i16, i32 or i64 for now. ";
881+
diag.add(diag::Diagnostic(
882+
var_annotation + " type is not supported yet. ",
883+
diag::Level::Error, diag::Stage::Semantic, {
884+
diag::Label(msg, {loc})
885+
})
886+
);
887+
throw SemanticAbort();
888+
} else {
883889
throw SemanticError("Unsupported type annotation: " + var_annotation, loc);
884890
}
885891
}

0 commit comments

Comments
 (0)