From ce160b4f1a3dd8c3e9d6add1adce893a95a1e784 Mon Sep 17 00:00:00 2001 From: ceriel Date: Tue, 22 Apr 1986 23:22:19 +0000 Subject: [PATCH] newer version --- lang/m2/comp/chk_expr.c | 11 +++++++---- lang/m2/comp/declar.g | 2 +- lang/m2/comp/typequiv.c | 4 ++++ lang/m2/comp/walk.c | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lang/m2/comp/chk_expr.c b/lang/m2/comp/chk_expr.c index bf9c58c34..22d91ea74 100644 --- a/lang/m2/comp/chk_expr.c +++ b/lang/m2/comp/chk_expr.c @@ -369,7 +369,7 @@ left->nd_def->df_idf->id_text, left->nd_def->df_value.df_stdname)); /* A dynamic array has no explicit index type */ - expp->nd_type = int_type; + expp->nd_type = intorcard_type; } else cstcall(expp, S_MAX); break; @@ -667,16 +667,19 @@ node_error(expp, "IN operator: type of LHS not compatible with element type of R } if (expp->nd_symb == '[') { - /* Handle ARRAY selection specially too! */ + /* Handle ARRAY selection specially too! + */ if (tpl->tp_fund != T_ARRAY) { node_error(expp, "array index not belonging to an ARRAY"); return 0; } - if (!TstCompat(tpl->next, tpr)) { + + if ((tpl->next && !TstCompat(tpl->next, tpr)) || + (!tpl->next && !TstCompat(intorcard_type, tpr)) { node_error(expp, "incompatible index type"); - return 0; } + expp->nd_type = tpl->arr_elem; return 1; } diff --git a/lang/m2/comp/declar.g b/lang/m2/comp/declar.g index b42921fee..abd63d34d 100644 --- a/lang/m2/comp/declar.g +++ b/lang/m2/comp/declar.g @@ -61,7 +61,7 @@ ProcedureHeading(struct def **pdf; int type;) /* We already saw a definition of this type in the definition module. */ - if (!TstTypeEquiv(tp, df->df_type)) { + if (!TstProcEquiv(tp, df->df_type)) { error("inconsistent procedure declaration for \"%s\"", df->df_idf->id_text); } FreeType(df->df_type); diff --git a/lang/m2/comp/typequiv.c b/lang/m2/comp/typequiv.c index 3054afc35..4c48a3058 100644 --- a/lang/m2/comp/typequiv.c +++ b/lang/m2/comp/typequiv.c @@ -95,6 +95,10 @@ TstCompat(tp1, tp2) && (tp2 == int_type || tp2 == card_type) ) + || + (tp1 == char_type && tp2 == charc_type) + || + (tp2 == char_type && tp1 == charc_type) || ( tp2 == intorcard_type && diff --git a/lang/m2/comp/walk.c b/lang/m2/comp/walk.c index 653b6db6f..6324b8beb 100644 --- a/lang/m2/comp/walk.c +++ b/lang/m2/comp/walk.c @@ -272,7 +272,7 @@ ExpectBool(nd) chk_expr(nd); - if (nd->nd_type != bool_type) { + if (nd->nd_type != bool_type && nd->nd_type != error_type) { node_error(nd, "boolean expression expected"); } -- 2.34.1