File tree 1 file changed +12
-0
lines changed 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -1737,6 +1737,18 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
1737
1737
this ->visit_expr (*x.m_value );
1738
1738
value = ASRUtils::EXPR (tmp);
1739
1739
value = cast_helper (type, value, true );
1740
+ if (!ASRUtils::check_equal_type (type, ASRUtils::expr_type (value))) {
1741
+ std::string ltype = ASRUtils::type_to_str (type);
1742
+ std::string rtype = ASRUtils::type_to_str (ASRUtils::expr_type (value));
1743
+ diag.add (diag::Diagnostic (
1744
+ " Type mismatch for an annotation-assignment. In LPython, the types must be compatible." ,
1745
+ diag::Level::Error, diag::Stage::Semantic, {
1746
+ diag::Label (" type mismatch (" + ltype + " and " + rtype + " )" ,
1747
+ {x.m_target ->base .loc , value->base .loc })
1748
+ })
1749
+ );
1750
+ throw SemanticAbort ();
1751
+ }
1740
1752
}
1741
1753
ASR::expr_t *init_expr = nullptr ;
1742
1754
ASR::intentType s_intent = ASRUtils::intent_local;
You can’t perform that action at this time.
0 commit comments