Valid-comp-stmt
Validate a compound statement.
- Signature
(valid-comp-stmt cstmt fundefp table ienv)
→
(mv erp new-cstmt return-types last-expr-type? new-table)
- Arguments
- cstmt — Guard (comp-stmtp cstmt).
- fundefp — Guard (booleanp fundefp).
- table — Guard (valid-tablep table).
- ienv — Guard (ienvp ienv).
- Returns
- erp — Type (maybe-msgp erp).
- new-cstmt — Type (comp-stmtp new-cstmt).
- return-types — Type (type-setp return-types).
- last-expr-type? — Type (type-optionp last-expr-type?).
- new-table — Type (valid-tablep new-table).
If validation is successful, we return the same kind of type results
as valid-stmt (see that function's documentation),
with the modification that
the last-expr-type? result is a type exactly when
the list of block items is not empty
and the validation of the last block item
returns a type as that result.
The fundefp flag says whether the compound statement
is the body of a function definition.
If that is the case, we do not push a new scope and then pop it,
because that is already done in valid-fundef:
the body itself of the function does not start a new scope;
it is the function definition itself that starts a new scope,
involving the parameters.