updating documents and small bugfix
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 7 Jan 2021 22:32:26 +0000 (16:32 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 7 Jan 2021 22:32:26 +0000 (16:32 -0600)
bin/test
docs/bugs
docs/watchout [new file with mode: 0644]
src/onyxchecker.c

index 826d5e3c65247d860c6058b11cb30e02e7dba3f6..d327cc40e947d3d92a47b1aef4d51f2c4b230c0e 100755 (executable)
--- a/bin/test
+++ b/bin/test
@@ -6,27 +6,29 @@ for test_file in $(find tests/ -name '*.onyx'); do
     dirname="$(dirname -- "$test_file")"
     name="${filename%.*}"
 
-    echo "⏲ Checking $name.onyx"
+    printf "%-$((($(tput cols) - 8)))s" "⏲ Checking $name.onyx"
 
     if ! ./bin/onyx "$test_file" -o "./tests/$name.wasm" >/dev/null; then
-        echo "❌ Failed to compile $name.onyx."
+        print "\n❌ Failed to compile $name.onyx.\n"
         failed=1
         continue
     fi
     
     if ! ./bin/onyx-js "./tests/$name.wasm" > ./tmpoutput; then
-        echo "❌ Failed to run $name.onyx."
+        print "\n❌ Failed to run $name.onyx.\n"
         failed=1
         continue
     fi
 
     if ! diff ./tmpoutput "$dirname/$name" >/dev/null; then
-        echo "❌ Test output did not match."
+        print "\n❌ Test output did not match.\n"
         diff ./tmpoutput "$dirname/$name"
         # failed=0
         continue
     fi
 
+    echo "✔ Passed"
+
     rm "./tests/$name.wasm"
 done
 rm ./tmpoutput
index 56bdc2eb02eb3d005aac1815a9ca638dd2c96ccc..1b282cb343bc366d1f9fa8ebda304ce148b7450a 100644 (file)
--- a/docs/bugs
+++ b/docs/bugs
@@ -25,7 +25,7 @@ List of known bugs:
     which is doesn't match the second one, when the original parameters would
     have matched correctly.
 
-[ ] `defer` statements are not executed at the end of a loop if the loop is
+[X] `defer` statements are not executed at the end of a loop if the loop is
     exited using a `break` statement, or a `continue` statement. The semantics
     of this need to change because it is not expected behaviour. Also it would
     prevent the usefulness of this pattern:
diff --git a/docs/watchout b/docs/watchout
new file mode 100644 (file)
index 0000000..cec0516
--- /dev/null
@@ -0,0 +1,18 @@
+Some tags to watch out for in the code with features that may be removed in the future:
+
+    :ValueDirectiveHack
+        In the same way #type can be used to express a type expression
+        in a value context, #value can be used to express a value expression
+        in a type context, such as a #solidify directive.
+
+    :NullProcHack
+        There are many times where being able to store a procedure that
+        is 'null' is useful, such as a vtable-like structure that doesn't
+        need all members defined. For this reason, `null_proc` was added.
+        It type matches against all procedure types without an error, allowing
+        it to be used wherever a procedure was expected. Also, before calling
+        a dynamic procedure, it should be checked against `null_proc`.
+
+        The implementation of `null_proc` is rather simple, but feels a
+        little verbose an targential compared to everything else being done
+        in the compiler.
\ No newline at end of file
index ba3596afb884246b30ebb17c85617c8c6d284a79..39428feb27950c04df60bba8d7eb7f775ea7dae0 100644 (file)
@@ -1440,16 +1440,15 @@ CheckStatus check_statement_chain(AstNode* start) {
 CheckStatus check_block(AstBlock* block) {
     CHECK(statement_chain, block->body);
 
-    bh_table_each_start(AstTyped *, block->scope->symbols);
-        fill_in_type(value);
-
-        // if (value->type == NULL) {
-        //     onyx_report_error(value->token->pos,
-        //             "Unable to resolve type for local '%b'.",
-        //             value->token->text, value->token->length);
-        //     return 1;
-        // }
-    bh_table_each_end;
+    bh_arr_each(AstTyped *, value, block->allocate_exprs) {
+        fill_in_type(*value);
+        if ((*value)->type == NULL) {
+            onyx_report_error((*value)->token->pos,
+                    "Unable to resolve type for local '%b'.",
+                    (*value)->token->text, (*value)->token->length);
+            return 1;
+        }
+    }
 
     return Check_Success;
 }