diff options
-rw-r--r-- | src/Compile.hs | 1 | ||||
-rw-r--r-- | test/Main.hs | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/src/Compile.hs b/src/Compile.hs index 2652ed4..6e46f74 100644 --- a/src/Compile.hs +++ b/src/Compile.hs @@ -831,6 +831,7 @@ compile' env = \case resname <- genName' "ixres" emit $ SVarDecl True (repSTy t) resname (CEIndex (CELit (arrname ++ ".buf->xs")) (toLinearIdx n arrname idxname)) + incrementVarAlways "idxelt" Increment t resname incrementVarAlways "idx" Decrement (STArr n t) arrname return (CELit resname) diff --git a/test/Main.hs b/test/Main.hs index be15e65..20b4ef0 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -471,7 +471,8 @@ tests_AD = testGroup "AD" -- Regression test for a simplifier bug (89b78d4) ,adTestTp "regression-simpl1" (C "" 1) term_regression_simpl1 - ,adTestTp "regression-accum1" (C "" 1 :$ C "" 1) $ + -- Regression test for refcounts when indexing in nested arrays + ,adTestTp "regression-idx1" (C "" 1 :$ C "" 1) $ fromNamed $ lambda @(TArr N2 R) #L $ body $ if_ (const_ @TI64 1 Language..> 0) (idx0 $ sum1i (build1 1 $ #_ :-> |