summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c5
-rw-r--r--test.toc20
-rw-r--r--types.c16
3 files changed, 17 insertions, 24 deletions
diff --git a/main.c b/main.c
index 0f84c4e..720dbdf 100644
--- a/main.c
+++ b/main.c
@@ -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
diff --git a/test.toc b/test.toc
index 7b57b1b..96b180a 100644
--- a/test.toc
+++ b/test.toc
@@ -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
diff --git a/types.c b/types.c
index 560f0fc..6765314 100644
--- a/types.c
+++ b/types.c
@@ -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: