@@ -273,11 +273,12 @@ qualifiedToJS _ f (Qualified _ a) = JSVar $ identToJs (f a)
273273bindersToJs :: (Functor m, Applicative m, Monad m) => Options -> ModuleName -> Environment -> [CaseAlternative] -> [JS] -> SupplyT m JS
274274bindersToJs opts m e binders vals = do
275275 valNames <- replicateM (length vals) freshName
276+ let assignments = zipWith JSVariableIntroduction valNames (map Just vals)
276277 jss <- forM binders $ \(CaseAlternative bs grd result) -> do
277278 ret <- valueToJs opts m (bindNames m (concatMap binderNames bs) e) result
278279 go valNames [JSReturn ret] bs grd
279− return $ JSApp (JSFunction Nothing valNames (JSBlock (concat jss ++ [JSThrow (JSStringLiteral "Failed pattern match")])))
280− vals
280+ return $ JSApp (JSFunction Nothing [] (JSBlock (assignments ++ concat jss ++ [JSThrow (JSStringLiteral "Failed pattern match")])))
281+ []
281282 where
282283 go :: (Functor m, Applicative m, Monad m) => [String] -> [JS] -> [Binder] -> Maybe Guard -> SupplyT m [JS]
283284 go _ done [] Nothing = return done