From 0d37c2671425c5a106a75f6c379e3190d8b0b019 Mon Sep 17 00:00:00 2001 From: drug007 Date: Sun, 9 Jan 2022 17:45:36 +0300 Subject: [PATCH 1/2] Close #34 `sdl example not building by ldc2` Work around ldc2 issue --- auxil/source/auxil/model.d | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/auxil/source/auxil/model.d b/auxil/source/auxil/model.d index 00d784cd..b3f40ade 100644 --- a/auxil/source/auxil/model.d +++ b/auxil/source/auxil/model.d @@ -955,7 +955,7 @@ mixin template visitImpl() static if (hasTreePath) visitor.tree_path.put(0); static if (hasTreePath) scope(exit) visitor.tree_path.popBack; - const len = getLength!(Data, data); + auto len = getLength!(Data, data); static if (is(typeof(model.length))) assert(len == model.length); if (!len) @@ -1000,14 +1000,17 @@ mixin template visitImpl() else static if (dataHasAggregateModel!Data) { scope(exit) dbgPrint!(hasSize, hasTreePath)("scope(exit) this.size: ", this.size); + // work around ldc2 issue + // expression `const len = getLength!(Data, data);` is not a constant + const len2 = DrawableMembers!Data.length; switch(start_value) { - static foreach(i; 0..len) + static foreach(i; 0..len2) { // reverse fields order if Order.Bubbling - case (Sinking) ? i : len - i - 1: + case (Sinking) ? i : len2 - i - 1: { - enum FieldNo = (Sinking) ? i : len - i - 1; + enum FieldNo = (Sinking) ? i : len2 - i - 1; enum member = DrawableMembers!Data[FieldNo]; static if (hasTreePath) visitor.tree_path.back = cast(int) FieldNo; static if (hasSize) scope(exit) this.size += mixin("this." ~ member).size; @@ -1022,9 +1025,9 @@ mixin template visitImpl() goto case; } // the dummy case needed because every `goto case` should be followed by a case clause - case len: + case len2: // flow cannot get here directly - if (start_value == len) + if (start_value == len2) assert(0); break; default: From dafdf7aaa2cbe7adfe49bef69c9425d62ede9a6c Mon Sep 17 00:00:00 2001 From: drug007 Date: Sun, 9 Jan 2022 17:51:46 +0300 Subject: [PATCH 2/2] Enable ldc2 in github actions --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 42cf3097..5318eb4f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: matrix: # Latest stable version, update at will os: [ ubuntu-18.04, windows-2019 ] - dc: [ dmd-latest, dmd-master ] + dc: [ dmd-latest, dmd-master, ldc-master, ldc-latest ] runs-on: ${{ matrix.os }} steps: