commit 4414790f9d6106b74a3f7c3f24e24bd4de5a90b3
parent d7d718c343f3a1f835a80dd66cf86a21ffb2638a
Author: m21c <ho*******@gmail.com>
Date: Thu, 2 Feb 2023 05:12:05 +0100
fixed check error-type + added FALLTHROUGH comments + minor fixes
Diffstat:
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/compiler.c b/compiler.c
@@ -2019,7 +2019,7 @@ expect(Source *source, int kind, const char *fmt, ...)
int column = source->tok.loc.column;
const char *filename = source->tok.loc.filename;
- if (getkind(source) != kind) {
+ if (getkind(source) != (Kind) kind) {
va_start(ap, fmt);
fprintf(stderr, "%s:%i:%i: error: ",
filename, line, column + 1);
@@ -3105,6 +3105,7 @@ isinttype(Type *ty)
case TS16: case TU16:
case TS32: case TU32:
case TS64: case TU64:
+ case TERRTYPE: /* avoiding error-reporting on error-type */
return true;
/* FIXME(m21c): This *just* tests wether a tuple only contains types of
@@ -3130,6 +3131,7 @@ isintorbooltype(Type *ty)
case TS16: case TU16:
case TS32: case TU32:
case TS64: case TU64:
+ case TERRTYPE: /* avoiding error-reporting on error-type */
return true;
/* FIXME(m21c): This *just* tests wether a tuple only contains types of
@@ -3150,6 +3152,7 @@ isfloattype(Type *ty)
{
switch (ty->kind) {
case TF32: case TF64:
+ case TERRTYPE: /* avoiding error-reporting on error-type */
return true;
/* FIXME(m21c): This *just* tests wether a tuple only contains types of
@@ -3176,6 +3179,7 @@ isarithtype(Type *ty)
case TS32: case TU32:
case TS64: case TU64:
case TF32: case TF64:
+ case TERRTYPE: /* avoiding error-reporting on error-type */
return true;
/* FIXME(m21c): This *just* tests wether a tuple only contains types of
@@ -3199,6 +3203,7 @@ isunsignedtype(Type *ty)
case TUINFER:
case TU8: case TU16:
case TU32: case TU64:
+ case TERRTYPE: /* avoiding error-reporting on error-type */
return true;
/* FIXME(m21c): This *just* tests wether a tuple only contains types of
@@ -3223,6 +3228,7 @@ islvalue(Node *node)
case ADECLREF:
case ADEREF:
case ADECL:
+ case TERRTYPE: /* avoiding error-reporting on error-type */
return true;
case ACOMMA:
@@ -3717,6 +3723,7 @@ typecheck(Env *env, Node *expr)
joincomma:
lhs = expr->lhs;
rhs = expr->rhs;
+ /* FALLTHROUGH */
case ACOMMA:
assert(lhs);
assert(rhs);
@@ -3846,6 +3853,7 @@ foldexpr(Env *env, Node *expr)
switch (getnumops(expr->kind)) {
case 2:
rhs = foldexpr(env, rhs);
+ /* FALLTHROUGH */
case 1:
lhs = foldexpr(env, lhs);
}
@@ -4020,6 +4028,7 @@ foldexpr(Env *env, Node *expr)
case TYPE:
error(&expr->loc, "exptected expression, not type");
+ /* FALLTHROUGH */
default:
return expr;
@@ -5182,6 +5191,8 @@ printexpr(FILE *out, Node *expr, int indent)
case KIF:
n += highlight(out, HLKEYWORD);
n += fprintf(out, "if ");
+ /* FALLTHROUGH */
+ joinifelse:
n += printexpr(out, expr->u.payload, indent);
n += printclause(out, expr->lhs, indent);