Fixed `getStatements()` for Module container type to be stable. Not having it so caused bad affects and re-ordering that should have NOT happened

This commit is contained in:
Tristan B. Velloza Kildaire 2021-11-09 16:50:04 +02:00
parent 7fe3ea342c
commit b39fea5e10
3 changed files with 30 additions and 1 deletions

View File

@ -37,14 +37,21 @@ public class Module : Entity, Container
{
/* Re-ordered by lowest wieght first */
Statement[] stmntsRed;
import gogga;
bool wCmp(Statement lhs, Statement rhs)
{
gprintln("LHS:"~lhs.toString());
gprintln("RHS:"~rhs.toString());
return lhs.weight < rhs.weight;
}
import std.algorithm.sorting;
stmntsRed = sort!(wCmp)(statements).release;
import std.algorithm.mutation : SwapStrategy;
stmntsRed = sort!(wCmp, SwapStrategy.stable)(statements).release;
gprintln(statements);
return stmntsRed;
}

View File

@ -0,0 +1,11 @@
module typeChecking3;
int p = 21;
p=2+p;
void main()
{
}

View File

@ -0,0 +1,11 @@
module typeChecking3;
int p = 21;
p=2+p;
void main()
{
}