diff options
-rw-r--r-- | main.c | 5 | ||||
-rw-r--r-- | test.toc | 20 | ||||
-rw-r--r-- | types.c | 16 |
3 files changed, 17 insertions, 24 deletions
@@ -18,10 +18,7 @@ /* TODO: -check for leaks ---- -warn about non-anonymous namespace statements of expression with compile-only types (e.g. int;) -allow for circular dependencies in functions returning types---this will be complicated +struct parameters - to allow circular dependencies in types foo, _ := bar(); nice syntax for #including something into a namespace run stuff at compile time without assigning it to a constant @@ -2,19 +2,7 @@ io ::= nms { #include "std/io.toc"; }; -n ::= nms { - #export x := 1; - #export counter ::= fn() int { x += 1; x }; -}; - - -#export main ::= fn() { - a := n.counter(); - b := n.counter(); - n.counter(); - c := n.counter(); - io.puts("Hello!"); - io.puti(a); - io.puti(b); - io.puti(c); -}; +main ::= fn() { + io.puts("Hello"); + int; +};
\ No newline at end of file @@ -2422,10 +2422,18 @@ static bool types_stmt(Typer *tr, Statement *s) { if (!types_expr(tr, &s->expr)) { return false; } - - if (s->expr.kind == EXPR_TUPLE && !(s->flags & STMT_EXPR_NO_SEMICOLON)) { - err_print(s->where, "Statement of a tuple is not allowed. Use a semicolon instead of a comma here."); - return false; + + if (!(s->flags & STMT_EXPR_NO_SEMICOLON)) { + if (s->expr.kind == EXPR_TUPLE) { + err_print(s->where, "Statement of a tuple is not allowed. Use a semicolon instead of a comma here."); + return false; + } + Type *t = &s->expr.type; + if (type_is_compileonly(t)) { + char *str = type_to_str(t); + warn_print(s->where, "This expression has a compile-only type (%s), so this statement will not actually be outputted in C code.", str); + free(str); + } } break; case STMT_DECL: |