Remove {} for empty sets

This commit is contained in:
Bruce Hill 2025-04-05 10:51:07 -04:00
parent c9198cb480
commit 53f5178f71
2 changed files with 4 additions and 7 deletions

View File

@ -12,16 +12,17 @@ b := {20, 30}
## Syntax
Sets are written using `{}` curly braces with comma-separated items:
Sets are written using `{...}` curly braces with comma-separated items:
```tomo
nums := {10, 20, 30}
```
Empty sets must specify the item type explicitly:
Empty sets must specify the set type explicitly and use `{/}` for an empty set
(because `{}` is an empty table).
```tomo
empty : {Int} = {}
empty : {Int} = {/}
```
For type annotations, a set that holds items with type `T` is written as `{T}`.

View File

@ -2010,10 +2010,6 @@ CORD compile_to_type(env_t *env, ast_t *ast, type_t *t)
return compile_typed_table(env, ast, t);
} else if (t->tag == SetType && ast->tag == Set) {
return compile_typed_set(env, ast, t);
} else if (t->tag == SetType && ast->tag == Table) {
auto table = Match(ast, Table);
if (!table->default_value && !table->fallback && !table->entries)
return compile_to_type(env, WrapAST(ast, Set), t);
}
type_t *actual = get_type(env, ast);