@@ -1070,32 +1070,32 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
1070
1070
if (var_sym->m_type ->type == ASR::ttypeType::TypeParameter) {
1071
1071
ASR::TypeParameter_t *type_param = ASR::down_cast<ASR::TypeParameter_t>(var_sym->m_type );
1072
1072
type = ASRUtils::TYPE (ASR::make_TypeParameter_t (al, loc, type_param->m_param ));
1073
- return ASRUtils::make_Array_t_util (al, loc, type, dims.p , dims.size ());
1073
+ type = ASRUtils::make_Array_t_util (al, loc, type, dims.p , dims.size ());
1074
1074
}
1075
1075
} else {
1076
1076
ASR::symbol_t *der_sym = ASRUtils::symbol_get_past_external (s);
1077
1077
if ( der_sym ) {
1078
1078
if ( ASR::is_a<ASR::StructType_t>(*der_sym) ) {
1079
1079
type = ASRUtils::TYPE (ASR::make_Struct_t (al, loc, s));
1080
- return ASRUtils::make_Array_t_util (al, loc, type, dims.p , dims.size ());
1080
+ type = ASRUtils::make_Array_t_util (al, loc, type, dims.p , dims.size ());
1081
1081
} else if ( ASR::is_a<ASR::EnumType_t>(*der_sym) ) {
1082
1082
type = ASRUtils::TYPE (ASR::make_Enum_t (al, loc, s));
1083
- return ASRUtils::make_Array_t_util (al, loc, type, dims.p , dims.size ());
1083
+ type = ASRUtils::make_Array_t_util (al, loc, type, dims.p , dims.size ());
1084
1084
} else if ( ASR::is_a<ASR::UnionType_t>(*der_sym) ) {
1085
1085
type = ASRUtils::TYPE (ASR::make_Union_t (al, loc, s));
1086
- return ASRUtils::make_Array_t_util (al, loc, type, dims.p , dims.size ());
1086
+ type = ASRUtils::make_Array_t_util (al, loc, type, dims.p , dims.size ());
1087
1087
}
1088
1088
}
1089
1089
}
1090
1090
} else if (var_annotation == " S" ) {
1091
1091
type = ASRUtils::TYPE (ASR::make_SymbolicExpression_t (al, loc));
1092
- return type;
1093
- }
1094
- if ( raise_error ) {
1095
- throw SemanticError (" Unsupported type annotation: " + var_annotation, loc);
1096
1092
}
1097
1093
}
1098
1094
1095
+ if ( !type && raise_error ) {
1096
+ throw SemanticError (" Unsupported type annotation: " + var_annotation, loc);
1097
+ }
1098
+
1099
1099
return type;
1100
1100
}
1101
1101
@@ -1669,7 +1669,10 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
1669
1669
if (AST::is_a<AST::Name_t>(annotation)) {
1670
1670
AST::Name_t *n = AST::down_cast<AST::Name_t>(&annotation);
1671
1671
var_annotation = n->m_id ;
1672
- } else if (AST::is_a<AST::Subscript_t>(annotation)) {
1672
+ return get_type_from_var_annotation (var_annotation, annotation.base .loc , dims, m_args, n_args, raise_error);
1673
+ }
1674
+
1675
+ if (AST::is_a<AST::Subscript_t>(annotation)) {
1673
1676
AST::Subscript_t *s = AST::down_cast<AST::Subscript_t>(&annotation);
1674
1677
if (AST::is_a<AST::Name_t>(*s->m_value )) {
1675
1678
AST::Name_t *n = AST::down_cast<AST::Name_t>(s->m_value );
@@ -1679,6 +1682,10 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
1679
1682
loc);
1680
1683
}
1681
1684
1685
+ if (var_annotation == " In" || var_annotation == " InOut" || var_annotation == " Out" ) {
1686
+ throw SemanticError (" Intent annotation '" + var_annotation + " ' cannot be used here" , s->base .base .loc );
1687
+ }
1688
+
1682
1689
if (var_annotation == " tuple" ) {
1683
1690
Vec<ASR::ttype_t *> types;
1684
1691
types.reserve (al, 4 );
@@ -1771,6 +1778,8 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
1771
1778
ASR::ttype_t *type = ast_expr_to_asr_type (loc, *s->m_slice , is_allocatable);
1772
1779
return ASRUtils::TYPE (ASR::make_Const_t (al, loc, type));
1773
1780
} else {
1781
+ ASR::ttype_t * type = get_type_from_var_annotation (var_annotation, annotation.base .loc , dims, m_args, n_args, raise_error);
1782
+
1774
1783
if (AST::is_a<AST::Slice_t>(*s->m_slice )) {
1775
1784
ASR::dimension_t dim;
1776
1785
dim.loc = loc;
@@ -1793,6 +1802,12 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
1793
1802
ASR::expr_t *value = ASRUtils::EXPR (tmp);
1794
1803
fill_dims_for_asr_type (dims, value, loc);
1795
1804
}
1805
+
1806
+ if (ASRUtils::ttype_set_dimensions (&type, dims.p , dims.size (), al)) {
1807
+ return type;
1808
+ }
1809
+
1810
+ throw SemanticError (" ICE: Unable to set dimensions for: " + var_annotation, loc);
1796
1811
}
1797
1812
} else if (AST::is_a<AST::Attribute_t>(annotation)) {
1798
1813
AST::Attribute_t* attr_annotation = AST::down_cast<AST::Attribute_t>(&annotation);
@@ -1835,12 +1850,9 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
1835
1850
current_scope->add_symbol (import_name, import_struct_member);
1836
1851
}
1837
1852
return ASRUtils::TYPE (ASR::make_Union_t (al, attr_annotation->base .base .loc , import_struct_member));
1838
- } else {
1839
- throw SemanticError (" Only Name, Subscript, and Call supported for now in annotation of annotated assignment." ,
1840
- loc);
1841
1853
}
1842
1854
1843
- return get_type_from_var_annotation (var_annotation, annotation. base . loc , dims, m_args, n_args, raise_error );
1855
+ throw SemanticError ( " Only Name, Subscript, and Call supported for now in annotation of annotated assignment. " , loc );
1844
1856
}
1845
1857
1846
1858
ASR::expr_t *index_add_one (const Location &loc, ASR::expr_t *idx) {
0 commit comments