From 9609e11303a3f3cf0f256a885c64f4bce8de927b Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Sun, 6 Jun 2021 19:10:26 +0200 Subject: [PATCH] Process the class itself then too, because if it must be initted as it is referenced by a variable's type then we must do the initializtions (static) of said class first and then that variable is satisfied (it doesn't matter too much without an assignment expresison but would with it hence we definately want this. --- source/tlang/compiler/typecheck/dependancy.d | 3 +++ source/tlang/testing/typecheck/basic_dependence_correct1.t | 2 ++ 2 files changed, 5 insertions(+) diff --git a/source/tlang/compiler/typecheck/dependancy.d b/source/tlang/compiler/typecheck/dependancy.d index 6d26b8fa..f62b7cc8 100644 --- a/source/tlang/compiler/typecheck/dependancy.d +++ b/source/tlang/compiler/typecheck/dependancy.d @@ -118,7 +118,10 @@ public void dependancyGenerate(TypeChecker tc, Container container) * Above it means that because the type of `k` is `Person` and that is a * class type therefore the Person class should have its static constructor * run (=> all static members should be initialized) + * + * Okay, so we do all of the above SECOND, first the class must be checked itself */ + dependancyGenerate(tc, classType); encounter(tc, variable, classType); } else diff --git a/source/tlang/testing/typecheck/basic_dependence_correct1.t b/source/tlang/testing/typecheck/basic_dependence_correct1.t index 9272db60..be0cdf72 100644 --- a/source/tlang/testing/typecheck/basic_dependence_correct1.t +++ b/source/tlang/testing/typecheck/basic_dependence_correct1.t @@ -8,6 +8,8 @@ int jNumber; class A { + static int jStatic; + int jInstance; class C {