From f7a863172928cbaa3dc8eebeb858e09af2e137de Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:10:50 +0200 Subject: [PATCH 01/17] Update d.yml --- .github/workflows/d.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index 8ac08696..c37a97f4 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -63,6 +63,8 @@ jobs: uses: dlang-community/setup-dlang@v1 with: compiler: ${{ matrix.dc }} + - name: Install Doveralls (code coverage tool) + run: dub fetch doveralls - name: DUB unit tests with coverage run: dub test --coverage From 02fe3347ebd8434ef23fea27e939bbbf87c387bc Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:12:32 +0200 Subject: [PATCH 02/17] Update d.yml --- .github/workflows/d.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index c37a97f4..30a420ab 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -63,11 +63,15 @@ jobs: uses: dlang-community/setup-dlang@v1 with: compiler: ${{ matrix.dc }} + - name: Install Doveralls (code coverage tool) run: dub fetch doveralls - name: DUB unit tests with coverage run: dub test --coverage + + - name: Coverage upload + run: dub run doveralls - uses: actions/upload-artifact@v3 with: From caaf5ff4c466f1657702b64fff347d8185c3a408 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:14:55 +0200 Subject: [PATCH 03/17] Update d.yml --- .github/workflows/d.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index 30a420ab..f0567f7c 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -65,13 +65,15 @@ jobs: compiler: ${{ matrix.dc }} - name: Install Doveralls (code coverage tool) - run: dub fetch doveralls + run: | + wget -q -O - "http://bit.ly/Doveralls" | bash + chmod +x doveralls - name: DUB unit tests with coverage run: dub test --coverage - name: Coverage upload - run: dub run doveralls + run: ./doveralls - uses: actions/upload-artifact@v3 with: From d226cdf7613de2292be321d203e9c36eeca21d05 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:17:03 +0200 Subject: [PATCH 04/17] Update d.yml --- .github/workflows/d.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index f0567f7c..4cbed0da 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -66,7 +66,8 @@ jobs: - name: Install Doveralls (code coverage tool) run: | - wget -q -O - "http://bit.ly/Doveralls" | bash + wget -O doveralls "https://github.com/ColdenCullen/doveralls/releases/download/v1.1.5/doveralls_linux_travis" + mv doveralls_linux_travis doveralls chmod +x doveralls - name: DUB unit tests with coverage From 3cf280d1284ca224b9b9d26dd00e42efe51866aa Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:18:19 +0200 Subject: [PATCH 05/17] Update d.yml --- .github/workflows/d.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index 4cbed0da..1d87ca03 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -67,7 +67,7 @@ jobs: - name: Install Doveralls (code coverage tool) run: | wget -O doveralls "https://github.com/ColdenCullen/doveralls/releases/download/v1.1.5/doveralls_linux_travis" - mv doveralls_linux_travis doveralls + # mv doveralls_linux_travis doveralls chmod +x doveralls - name: DUB unit tests with coverage From 2417a5afe8eca424b8f1f102cdf3843248239dec Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:20:15 +0200 Subject: [PATCH 06/17] Update d.yml --- .github/workflows/d.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index 1d87ca03..b49ed4ec 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -66,15 +66,17 @@ jobs: - name: Install Doveralls (code coverage tool) run: | - wget -O doveralls "https://github.com/ColdenCullen/doveralls/releases/download/v1.1.5/doveralls_linux_travis" + # wget -O doveralls "https://github.com/ColdenCullen/doveralls/releases/download/v1.1.5/doveralls_linux_travis" # mv doveralls_linux_travis doveralls - chmod +x doveralls + # chmod +x doveralls + dub fetch doveralls + apt install libcurl-devel - name: DUB unit tests with coverage run: dub test --coverage - name: Coverage upload - run: ./doveralls + run: dub run doveralls - uses: actions/upload-artifact@v3 with: From 8201718774c5f2e1f23ff6695cbe003d5defbc2d Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:22:04 +0200 Subject: [PATCH 07/17] Update d.yml --- .github/workflows/d.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index b49ed4ec..75cccd54 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -70,7 +70,7 @@ jobs: # mv doveralls_linux_travis doveralls # chmod +x doveralls dub fetch doveralls - apt install libcurl-devel + sudo apt install libcurl-devel - name: DUB unit tests with coverage run: dub test --coverage From 1b9b68833761c51d2bf809bb80b15945ca1a29a6 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:23:20 +0200 Subject: [PATCH 08/17] Update d.yml --- .github/workflows/d.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index 75cccd54..876135f5 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -70,7 +70,7 @@ jobs: # mv doveralls_linux_travis doveralls # chmod +x doveralls dub fetch doveralls - sudo apt install libcurl-devel + sudo apt install libcurl-dev - name: DUB unit tests with coverage run: dub test --coverage From a8e3dae81fafdcb52e2af62033499c2325d529e2 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:25:38 +0200 Subject: [PATCH 09/17] Update d.yml --- .github/workflows/d.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index 876135f5..d453327e 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -70,7 +70,7 @@ jobs: # mv doveralls_linux_travis doveralls # chmod +x doveralls dub fetch doveralls - sudo apt install libcurl-dev + sudo apt install libcurl4-openssl-dev - name: DUB unit tests with coverage run: dub test --coverage From 706d5053db833dd4dd90aec3158890abbd1b80c5 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:30:20 +0200 Subject: [PATCH 10/17] Update d.yml --- .github/workflows/d.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index d453327e..63554ab2 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -63,6 +63,7 @@ jobs: uses: dlang-community/setup-dlang@v1 with: compiler: ${{ matrix.dc }} + repo_token: ${{COVERALLS_REPO_TOKEN}} - name: Install Doveralls (code coverage tool) run: | @@ -76,7 +77,7 @@ jobs: run: dub test --coverage - name: Coverage upload - run: dub run doveralls + run: dub run doveralls - uses: actions/upload-artifact@v3 with: From ef9a461de222d3c61d134bfe6a3b44b194a18cc7 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:33:12 +0200 Subject: [PATCH 11/17] Update d.yml --- .github/workflows/d.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index 63554ab2..28b56362 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -77,7 +77,7 @@ jobs: run: dub test --coverage - name: Coverage upload - run: dub run doveralls + run: dub run doveralls $COVERALLS_REPO_TOKEN - uses: actions/upload-artifact@v3 with: From e66b7750ab63fe8da1a42abd54aba5ef994bea8b Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:33:58 +0200 Subject: [PATCH 12/17] Update d.yml --- .github/workflows/d.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index 28b56362..274946c7 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -63,7 +63,6 @@ jobs: uses: dlang-community/setup-dlang@v1 with: compiler: ${{ matrix.dc }} - repo_token: ${{COVERALLS_REPO_TOKEN}} - name: Install Doveralls (code coverage tool) run: | From a60ce2a66fdc9104895eeffe26e80741974d280f Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:36:07 +0200 Subject: [PATCH 13/17] Update d.yml --- .github/workflows/d.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index 274946c7..6328c12e 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -76,7 +76,7 @@ jobs: run: dub test --coverage - name: Coverage upload - run: dub run doveralls $COVERALLS_REPO_TOKEN + run: dub run doveralls -- -t $COVERALLS_REPO_TOKEN - uses: actions/upload-artifact@v3 with: From 8831ea51de5041669b0e85bb0af333c3c2087a66 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:38:19 +0200 Subject: [PATCH 14/17] Update d.yml --- .github/workflows/d.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index 6328c12e..f26284b9 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -76,7 +76,7 @@ jobs: run: dub test --coverage - name: Coverage upload - run: dub run doveralls -- -t $COVERALLS_REPO_TOKEN + run: dub run doveralls -- -t ${{secrets.COVERALLS_REPO_TOKEN}} - uses: actions/upload-artifact@v3 with: From f62ec5667f36c0cc4781c62d5601b7253085f850 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:41:22 +0200 Subject: [PATCH 15/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e4cf2f04..a28c63cc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ tlang ===== -[![D](https://github.com/tbklang/tlang/actions/workflows/d.yml/badge.svg?branch=vardec_varass_dependency)](https://github.com/tbklang/tlang/actions/workflows/d.yml) +[![D](https://github.com/tbklang/tlang/actions/workflows/d.yml/badge.svg?branch=vardec_varass_dependency)](https://github.com/tbklang/tlang/actions/workflows/d.yml) [![Coverage Status](https://coveralls.io/repos/github/tbklang/tlang/badge.svg?branch=vardec_varass_dependency)](https://coveralls.io/github/tbklang/tlang?branch=vardec_varass_dependency) Official Tristan Language project compiler From 16caf6ebec04961c7a5bd763c3d314525c1a1108 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 21 Aug 2023 14:57:12 +0200 Subject: [PATCH 16/17] Update d.yml --- .github/workflows/d.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index f26284b9..349dc59a 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -76,7 +76,9 @@ jobs: run: dub test --coverage - name: Coverage upload - run: dub run doveralls -- -t ${{secrets.COVERALLS_REPO_TOKEN}} + run: | + export CI_BRANCH=$(git branch --show-current) + dub run doveralls -- -t ${{secrets.COVERALLS_REPO_TOKEN}} - uses: actions/upload-artifact@v3 with: From e1d034cbe067e562de07fa979f1655bf193f5ae9 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Sun, 27 Aug 2023 12:53:18 +0200 Subject: [PATCH 17/17] =?UTF-8?q?=F0=9F=90=9E=EF=B8=8F=20Bugfix:=20Module-?= =?UTF-8?q?level=20static=20members=20may=20cause=20consecutive=20compilat?= =?UTF-8?q?ion=20errors=20(#30)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Compiler - Re-enabled compilation tests (partially) * Dependency - Fixed comment - Implemented `clearFuncDefs()` * TypeChecker - Clear the `FunctionData[string]` table after a batch of typechecking/codegen such that we don't have lingering data from previous compilations which gets reliniearzed resulting in an exception being thrown as it was marked as linearized from its first time from a previous compilation * Compiler - Re-enabled unit tests for compilation - Added TODO relating to adding failing test cases as well * Compiler - Added unit test for failing tests * TypeCheck - Use a scopre guard to call `clearFuncDefs()` such that it is called even when exceptions are thrown during depgen, typecheck/codegen ensuring we have it cleared for the next run * Compiler - Added `gibeFileData(string)` to easily read the source text - Added all `typecheck` (good and bad) tests * Pipelines - Updated name * Compiler (unittests) - Re-ordered the test cases - Commented them out * Compiler - Added documentation for `gibFileData(string)` - Made `gibFileData(string)` private * Compiler (unit tests) - Documented unit test * Compiler - Cleaned up imports * Compiler (unit tests) - Added TODO - Added spacing --- .github/workflows/d.yml | 2 +- source/tlang/compiler/core.d | 255 ++++++++++++++++-- source/tlang/compiler/typecheck/core.d | 9 +- .../compiler/typecheck/dependency/core.d | 21 +- 4 files changed, 263 insertions(+), 24 deletions(-) diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index 349dc59a..c4a81ada 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -429,7 +429,7 @@ jobs: run: | ./tlang compile source/tlang/testing/simple_function_decls.t ./tlang.out - - name: Simple function (only) decls + - name: Simple variables (only) decls run: | ./tlang compile source/tlang/testing/simple_variables_only_decs.t ./tlang.out diff --git a/source/tlang/compiler/core.d b/source/tlang/compiler/core.d index 2288be51..be2bb2f8 100644 --- a/source/tlang/compiler/core.d +++ b/source/tlang/compiler/core.d @@ -13,7 +13,7 @@ import tlang.compiler.typecheck.exceptions; import core.stdc.stdlib; import tlang.compiler.codegen.emit.core; import tlang.compiler.codegen.emit.dgen; -import misc.exceptions : TError; +import misc.exceptions; import tlang.compiler.codegen.mapper.core : SymbolMapper; import tlang.compiler.codegen.mapper.hashmapper : HashMapper; import tlang.compiler.codegen.mapper.lebanese : LebaneseMapper; @@ -247,6 +247,27 @@ public class Compiler } } +/** + * Opens the source file at the given path, reads the data + * and returns it + * + * Params: + * sourceFile = the path to the file to open + * Returns: the source data + */ +private string gibFileData(string sourceFile) +{ + File sourceFileFile; + sourceFileFile.open(sourceFile); /* TODO: Error handling with ANY file I/O */ + ulong fileSize = sourceFileFile.size(); + byte[] fileBytes; + fileBytes.length = fileSize; + fileBytes = sourceFileFile.rawRead(fileBytes); + sourceFileFile.close(); + + return cast(string)fileBytes; +} + /** * Performs compilation of the provided module(s) * @@ -283,26 +304,220 @@ void beginCompilation(string[] sourceFiles) } } +/** + * Tests the following pipeline: + * + * 1. lexing -> parsing -> typecheck/codegen -> emit (DGen) + * + * Kinds of tests: + * + * 1. Positive tests (must pass) + */ unittest { - // TODO: Add tests here for our `simple_.t` tests or put them in DGen, I think here is better - // FIXME: Crashes and I think because too fast or actually bad state? Maybe something is not being - // cleared, I believe this may be what is happening - // ... see issue #88 - // ... UPDATE: It seems to be any unit test..... mhhhh. - // string[] testFiles = ["source/tlang/testing/simple_while.t" - // ]; - - // // "source/tlang/testing/simple_functions.t", - // // "source/tlang/testing/simple_while.t", - // // "source/tlang/testing/simple_for_loops.t", - // // "source/tlang/testing/simple_cast.t", - // // "source/tlang/testing/simple_conditionals.t", - // // "source/tlang/testing/nested_conditionals.t", - // // "source/tlang/testing/simple_discard.t" - // foreach(string testFile; testFiles) - // { - // beginCompilation([testFile]); - // } + // TODO: Ensure up to date with d.yml + string[] testFiles = [ + "source/tlang/testing/simple_functions.t", + "source/tlang/testing/simple_direct_func_call.t", + "source/tlang/testing/simple_function_recursion_factorial.t", + + "source/tlang/testing/simple_conditionals.t", + "source/tlang/testing/nested_conditionals.t", + "source/tlang/testing/simple_function_decls.t", + "source/tlang/testing/simple_variables_only_decs.t", + "source/tlang/testing/simple_variables_decls_ass.t", + "source/tlang/testing/simple_while.t", + + "source/tlang/testing/simple_for_loops.t", + "source/tlang/testing/simple_cast.t", + + "source/tlang/testing/simple_pointer.t", + "source/tlang/testing/simple_pointer_cast_le.t", + + "source/tlang/testing/simple_stack_arrays4.t", + "source/tlang/testing/simple_stack_array_coerce.t", + "source/tlang/testing/simple_stack_array_coerce_ptr_syntax.t", + "source/tlang/testing/complex_stack_array_coerce.t", + + + "source/tlang/testing/complex_stack_arrays1.t", + "source/tlang/testing/simple_arrays.t", + "source/tlang/testing/simple_arrays2.t", + "source/tlang/testing/simple_arrays4.t", + + + "source/tlang/testing/simple_pointer_array_syntax.t", + ]; + foreach(string testFile; testFiles) + { + beginCompilation([testFile]); + } } +/** + * Tests the following pipeline: + * + * 1. lexing -> parsing -> typecheck/codegen -> emit (DGen) + * + * Kinds of tests: + * + * 1. Negative tests (must fail) + */ +unittest +{ + // TODO: Be specific about the catches maybe + string[] failingTestFiles = [ + "source/tlang/testing/simple_function_return_type_check_bad.t" + ]; + + foreach(string testFile; failingTestFiles) + { + try + { + beginCompilation([testFile]); + assert(false); + } + catch(TError) + { + assert(true); + } + catch(Exception e) + { + assert(false); + } + } +} + +/** + * Tests the following pipeline: + * + * 1. lexing -> parsing -> typecheck/codegen + * + * Kinds of tests: + * + * 1. Positive tests (must pass) + * 2. Negative tests (must fail) + */ +unittest +{ + // TODO: Enesure we keep this up-to-date with the d.yml + string[] testFilesGood = [ + "source/tlang/testing/return/simple_return_expressionless.t", + "source/tlang/testing/return/simple_return_type.t", + "source/tlang/testing/typecheck/simple_function_call.t", + + "source/tlang/testing/simple_arrays.t", + "source/tlang/testing/simple_arrays2.t", + "source/tlang/testing/simple_arrays4.t", + + "source/tlang/testing/simple_stack_array_coerce.t", + "source/tlang/testing/complex_stack_arrays1.t", + + "source/tlang/testing/complex_stack_array_coerce_permutation_good.t", + "source/tlang/testing/simple1_module_positive.t", + "source/tlang/testing/simple2_name_recognition.t", + + "source/tlang/testing/simple_literals.t", + "source/tlang/testing/simple_literals3.t", + "source/tlang/testing/simple_literals5.t", + "source/tlang/testing/simple_literals6.t", + "source/tlang/testing/universal_coerce/simple_coerce_literal_good.t", + "source/tlang/testing/universal_coerce/simple_coerce_literal_good_stdalo.t", + "source/tlang/testing/simple_function_return_type_check_good.t" + ]; + + foreach(string testFileGood; testFilesGood) + { + string sourceText = gibFileData(testFileGood); + + try + { + File tmpFile; + tmpFile.open("/tmp/bruh", "wb"); + Compiler compiler = new Compiler(sourceText, tmpFile); + + // Lex + compiler.doLex(); + + // Parse + compiler.doParse(); + + // Dep gen/typecheck/codegen + compiler.doTypeCheck(); + + assert(true); + } + // On Error + catch(TError e) + { + assert(false); + } + // On Error + catch(Exception e) + { + gprintln("Yo, we should not be getting this but rather ONLY TErrors, this is a bug to be fixed", DebugType.ERROR); + assert(false); + } + } + + // TODO: ENsure we keep this up to date with the d.yml + string[] testFilesFail = [ + "source/tlang/testing/typecheck/simple_function_call_1.t", + + "source/tlang/testing/simple_stack_array_coerce_wrong.t", + + "source/tlang/testing/complex_stack_array_coerce_bad1.t", + "source/tlang/testing/complex_stack_array_coerce_bad2.t", + "source/tlang/testing/complex_stack_array_coerce_bad3.t", + + "source/tlang/testing/collide_container_module1.t", + "source/tlang/testing/collide_container_module2.t", + "source/tlang/testing/collide_container_non_module.t", + "source/tlang/testing/collide_container.t", + "source/tlang/testing/collide_member.t", + "source/tlang/testing/precedence_collision_test.t", + + "source/tlang/testing/else_if_without_if.pl", + + "source/tlang/testing/simple_literals2.t", + "source/tlang/testing/simple_literals4.t", + "source/tlang/testing/universal_coerce/simple_coerce_literal_bad.t", + "source/tlang/testing/universal_coerce/simple_coerce_literal_bad_stdalon.t", + "source/tlang/testing/simple_function_return_type_check_bad.t" + ]; + + foreach(string testFileFail; testFilesFail) + { + string sourceText = gibFileData(testFileFail); + + try + { + File tmpFile; + tmpFile.open("/tmp/bruh", "wb"); + Compiler compiler = new Compiler(sourceText, tmpFile); + + // Lex + compiler.doLex(); + + // Parse + compiler.doParse(); + + // Dep gen/typecheck/codegen + compiler.doTypeCheck(); + + // All of these checks should be failing + assert(false); + } + // On Error + catch(TError e) + { + assert(true); + } + // We should ONLY be getting TErrors + catch(Exception e) + { + gprintln("Got non TError, this is a bug that must be fixed", DebugType.ERROR); + assert(false); + } + } +} \ No newline at end of file diff --git a/source/tlang/compiler/typecheck/core.d b/source/tlang/compiler/typecheck/core.d index 4b22e00d..aba289a9 100644 --- a/source/tlang/compiler/typecheck/core.d +++ b/source/tlang/compiler/typecheck/core.d @@ -107,6 +107,13 @@ public final class TypeChecker /* TODO: Implement me */ checkClassInherit(modulle); + // TODO: Issue 88: Don't use static state + scope(exit) + { + /* Clear the FunctionData map (for next compilation) */ + clearFuncDefs(); + } + /** * Dependency tree generation @@ -202,7 +209,7 @@ public final class TypeChecker gprintln("FUNCDEF DONE: "~to!(string)(functionBodyCodeQueues[funcData.name])); } - + // NOTE: Check scope guard for "exit routines" which run here } diff --git a/source/tlang/compiler/typecheck/dependency/core.d b/source/tlang/compiler/typecheck/dependency/core.d index 564723fb..7d7c88ba 100644 --- a/source/tlang/compiler/typecheck/dependency/core.d +++ b/source/tlang/compiler/typecheck/dependency/core.d @@ -98,13 +98,30 @@ private FunctionData[string] functions; /** -* Returns the declared functions -*/ + * Returns the declared functions + */ public FunctionData[string] grabFunctionDefs() { return functions; } +/** + * Clars the `FunctionData[string]` map + * + * This is called normally after the + * typechecking and code generation such + * that the module-static field inside + * this module can be cleared and not + * persist across compilations + */ +public void clearFuncDefs() +{ + foreach(string key; functions.keys()) + { + functions.remove(key); + } +} + /** * Creates a new FunctionData and adds it to the * list of declared functions