diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-12-06 13:54:37 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-12-06 13:54:37 -0500 |
| commit | a13b39f1e1ea220a868d99508796d06492a40611 (patch) | |
| tree | 74ebf34d5cb9ef661165b4815aa37de5aafc5c9c | |
| parent | 129f2c794cd388b99d573697965117e12b89f2fe (diff) | |
Allow discarding Empty() values
| -rw-r--r-- | CHANGES.md | 4 | ||||
| -rw-r--r-- | src/compile/statements.c | 2 | ||||
| -rw-r--r-- | src/typecheck.c | 2 |
3 files changed, 5 insertions, 3 deletions
@@ -1,5 +1,9 @@ # Version History +## v2025-12-06 + +- You can now discard Empty values. + ## v2025-11-30 ### API changes diff --git a/src/compile/statements.c b/src/compile/statements.c index 638f1341..4bb8b432 100644 --- a/src/compile/statements.c +++ b/src/compile/statements.c @@ -218,8 +218,6 @@ static Text_t _compile_statement(env_t *env, ast_t *ast) { } case Metadata: return EMPTY_TEXT; default: - // print("Is discardable: ", ast_to_sexp_str(ast), " ==> ", - // is_discardable(env, ast)); if (!is_discardable(env, ast)) code_err(ast, "The ", type_to_text(get_type(env, ast)), " result of this statement cannot be discarded"); return Texts("(void)", compile(env, ast), ";"); diff --git a/src/typecheck.c b/src/typecheck.c index e432759b..6f8fa0ba 100644 --- a/src/typecheck.c +++ b/src/typecheck.c @@ -1539,7 +1539,7 @@ PUREFUNC bool is_discardable(env_t *env, ast_t *ast) { default: break; } type_t *t = get_type(env, ast); - return (t->tag == VoidType || t->tag == AbortType || t->tag == ReturnType); + return (t->tag == VoidType || t->tag == AbortType || t->tag == ReturnType || t == EMPTY_TYPE); } type_t *get_arg_ast_type(env_t *env, arg_ast_t *arg) { |
