diff --git a/wasm-calc9/src/Calc/Linearity/Validate.hs b/wasm-calc9/src/Calc/Linearity/Validate.hs index 137db649..b976047c 100644 --- a/wasm-calc9/src/Calc/Linearity/Validate.hs +++ b/wasm-calc9/src/Calc/Linearity/Validate.hs @@ -184,7 +184,7 @@ addLetBinding (PWildcard ty) = do addLetBinding (PBox ty pat) = PBox (ty, Just DropMe) <$> addLetBinding pat addLetBinding (PTuple ty p ps) = do - PTuple (ty, Nothing) + PTuple (ty, Just DropMe) <$> addLetBinding p <*> traverse addLetBinding ps diff --git a/wasm-calc9/test/Test/Linearity/LinearitySpec.hs b/wasm-calc9/test/Test/Linearity/LinearitySpec.hs index 8e886144..0662ef55 100644 --- a/wasm-calc9/test/Test/Linearity/LinearitySpec.hs +++ b/wasm-calc9/test/Test/Linearity/LinearitySpec.hs @@ -19,7 +19,7 @@ runTC = runTypecheckM (TypecheckEnv mempty mempty 0) spec :: Spec spec = do - fdescribe "LinearitySpec" $ do + describe "LinearitySpec" $ do describe "decorate" $ do let dVar = EVar Nothing dBool = EPrim Nothing . PBool @@ -59,6 +59,15 @@ spec = do (EBox Nothing (EAnn Nothing dTyInt64 (dInt 100))) (dVar "a") ), + ( "function dropTupleAfterUse() -> Int64 { let (a,_) = ((100: Int64),(200: Int64)); a }", + ELet + Nothing + (PTuple (Just DropMe) (PVar Nothing "a") (NE.singleton $ PVar Nothing "_fresh_name1")) + (ETuple Nothing (EAnn Nothing dTyInt64 (dInt 100)) + (NE.singleton $ EAnn Nothing dTyInt64 (dInt 200)) + ) + (dVar "a") + ), ( "function incrementallyDropBoxesAfterUse() -> Int64 { let Box(outer) = Box(Box((100: Int64))); let Box(inner) = outer; inner }", ELet Nothing @@ -93,7 +102,7 @@ spec = do letAEqualsTuple ( ELet (dropIdents [("a", tyTuple [tyInt32, tyInt32])]) - (PTuple Nothing (PVar Nothing "b") (NE.singleton (PVar Nothing "c"))) + (PTuple (Just DropMe) (PVar Nothing "b") (NE.singleton (PVar Nothing "c"))) (dVar "a") (EInfix Nothing OpAdd (dVar "b") (dVar "c")) ) diff --git a/wasm-calc9/test/Test/Wasm/WasmSpec.hs b/wasm-calc9/test/Test/Wasm/WasmSpec.hs index e26b2c04..8a57ff4b 100644 --- a/wasm-calc9/test/Test/Wasm/WasmSpec.hs +++ b/wasm-calc9/test/Test/Wasm/WasmSpec.hs @@ -141,7 +141,7 @@ spec = do describe "From module" $ do traverse_ testWithNode testVals - fdescribe "Test with interpreter" $ do + describe "Test with interpreter" $ do let asTest str = "export function test() -> Int64 { " <> str <> " }" let testVals = [ (asTest "42", Wasm.VI64 42),