Skip to content

Commit

Permalink
Improved int semantic error message with hint (Issue lcompilers#1926)
Browse files Browse the repository at this point in the history
  • Loading branch information
NishantBansal2003 committed Feb 5, 2024
1 parent 7372627 commit 942cffe
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,15 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {

if( !type && raise_error ) {
if (var_annotation == "int") {
throw SemanticError(var_annotation + " type is not supported yet. " , loc);
} else
{
std::string msg = "Hint: Use i8, i16, i32 or i64 for now. ";
diag.add(diag::Diagnostic(
var_annotation + " type is not supported yet. ",
diag::Level::Error, diag::Stage::Semantic, {
diag::Label(msg, {loc})
})
);
throw SemanticAbort();
} else {
throw SemanticError("Unsupported type annotation: " + var_annotation, loc);
}
}
Expand Down

0 comments on commit 942cffe

Please sign in to comment.