Did not handle RETURN's in module bodies right

This commit is contained in:
ceriel 1990-11-22 09:49:37 +00:00
parent d99b166621
commit b2bee3043a

View file

@ -258,6 +258,7 @@ WithStatement(t_node **pnd;)
ReturnStatement(t_node **pnd;)
{
register t_def *df = CurrentScope->sc_definedby;
register t_type *tp = df->df_type ? ResultType(df->df_type) : 0;
register t_node *nd;
} :
@ -267,12 +268,12 @@ ReturnStatement(t_node **pnd;)
{ if (scopeclosed(CurrentScope)) {
error("a module body cannot return a value");
}
else if (! ResultType(df->df_type)) {
else if (! tp) {
error("procedure \"%s\" is not a function, so cannot return a value", df->df_idf->id_text);
}
}
|
{ if (ResultType(df->df_type)) {
{ if (tp) {
error("function procedure \"%s\" must return a value", df->df_idf->id_text);
}
}