From 5c3cd6d7e7e21bbfb115c91ba9459a38e5e7eea5 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 7 Jan 2021 16:32:26 -0600 Subject: [PATCH] updating documents and small bugfix --- bin/test | 10 ++++++---- docs/bugs | 2 +- docs/watchout | 18 ++++++++++++++++++ src/onyxchecker.c | 19 +++++++++---------- 4 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 docs/watchout diff --git a/bin/test b/bin/test index 826d5e3c..d327cc40 100755 --- 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 diff --git a/docs/bugs b/docs/bugs index 56bdc2eb..1b282cb3 100644 --- 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 index 00000000..cec05161 --- /dev/null +++ b/docs/watchout @@ -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 diff --git a/src/onyxchecker.c b/src/onyxchecker.c index ba3596af..39428feb 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -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; } -- 2.25.1